import { createMachine, interpret } from 'xstate';

const validationMachine = createMachine({
    id: 'validation',
    initial: 'notValidated',
    states: {
        notValidated: {
            on: {
                VALIDATE: 'validated'
            }
        },
        validated: {
            on: {
                INVALIDATE: 'notValidated'
            }
        }
    }
});


export function validateMe() {
    const service = interpret(validationMachine).onTransition((state) => {
        console.log('Current validation state:', state.value);
    }).start();

    return service;
}