{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "This is a json-schema for the statemachines as defined by the php izzum library. see http://jsonschemalint.com/draft4/# to validate your json definitions",
    "properties": {
        "comment": {
            "description": "comments for the description of the file contents can be placed here.",
            "type": [
                "string",
                "null"
            ]
        },
        "machines": {
            "description": "All machines are defined here",
            "items": {
                "description": "A full machine definition",
                "properties": {
                    "description": {
                        "description": "a description of the machine",
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "factory": {
                        "description": "\\fully\\qualified\\Factory class name",
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "name": {
                        "description": "the name of the machine",
                        "pattern": "^([a-z0-9])+((-)?([a-z0-9])+)*$",
                        "type": "string"
                    },
                    "states": {
                        "description": "All state definitions for a machine go in this array",
                        "items": {
                            "description": "A state definition",
                            "properties": {
                                "description": {
                                    "description": "A description of the state",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "entry_callable": {
                                    "description": "A php callable for state entry. can only be in form of fully\\qualified\\Class::staticMethod",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "entry_command": {
                                    "description": "\\fully\\qualified\\Command (multiple can be comma seperated) that will be executed on entry of the state",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "exit_callable": {
                                    "description": "A php callable for state exit. can only be in form of fully\\qualified\\Class::staticMethod",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "exit_command": {
                                    "description": "\\fully\\qualified\\Command name (multiple can be comma seperated) that will be executed on exit of the state",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "name": {
                                    "description": "the state name",
                                    "pattern": "^([a-z0-9])+((-)?([a-z0-9])+)*$|^(not-)?regex:(.*)$",
                                    "type": "string"
                                },
                                "type": {
                                    "description": "the type of state: initial (1), normal(0..n), final (1..n) or regex (0..n)",
                                    "enum": [
                                        "initial",
                                        "normal",
                                        "final",
                                        "regex"
                                    ]
                                }
                            },
                            "required": [
                                "name",
                                "type"
                            ],
                            "type": "object"
                        },
                        "minItems": 2,
                        "type": "array",
                        "_uniqueItems": true
                    },
                    "transitions": {
                        "description": "A list of transitions, referring to the states",
                        "items": {
                            "description": "A transition definition",
                            "properties": {
                                "command": {
                                    "description": "\\fully\\qualified\\Command name (multiple can be comma seperated) that will be executed as the transition logic",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "description": {
                                    "description": "The description of the transition",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "event": {
                                    "description": "an event name by which you can call this transition",
                                    "pattern": "^[a-zA-Z0-9]+$",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "guard_callable": {
                                    "description": "A php callable for guard logic. can only be in form of fully\\qualified\\Class::staticMethod",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "rule": {
                                    "description": "\\fully\\qualified\\Rule name (multiple can be comma seperated) that will be checked as boolean guard logic before the transition",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "state_from": {
                                    "description": "the state from which the transition is made. this can be a regex.",
                                    "pattern": "^([a-z0-9])+((-)?([a-z0-9])+)*$|^(not-)?regex:(.*)$",
                                    "type": "string"
                                },
                                "state_to": {
                                    "description": "the state to which the transition is made. this can be a regex.",
                                    "pattern": "^([a-z0-9])+((-)?([a-z0-9])+)*$|^(not-)?regex:(.*)$",
                                    "type": "string"
                                },
                                "transition_callable": {
                                    "description": "A php callable for transition logic. can only be in form of fully\\qualified\\Class::staticMethod",
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                }
                            },
                            "required": [
                                "state_from",
                                "state_to",
                                "event"
                            ],
                            "type": "object"
                        },
                        "minItems": 1,
                        "type": "array",
                        "_uniqueItems": true
                    }
                },
                "required": [
                    "name",
                    "description",
                    "states",
                    "transitions"
                ],
                "type": "object"
            },
            "minItems": 1,
            "type": "array",
            "_uniqueItems": true
        }
    },
    "required": [
        "machines"
    ],
    "title": "izzum statemachines definitions schema",
    "type": "object"
}