Replies: 2 comments
-
This would definitely be of value. My perspective on validation includes JSON Schema validation, but goes beyond that - we also want to check that there are no "orphaned" states with no transitions to it, that there are no "sink" states with no outgoing transitions, that parallel states have more than one "region" (child state), etc. |
Beta Was this translation helpful? Give feedback.
-
@davidkpiano that sounds like a great idea, and I do think having all of these validations would be amazing. |
Beta Was this translation helpful? Give feedback.
-
There might be use-cases where the xstate library is served behind an API/Service. In such cases, where new statecharts can be authored on the fly, it might be really helpful to have a
validateMachineConfig
util method.Possible implementation
This can be potentially done using the existing machine.schema.json, like shown in json.test.ts
Potentially this can be achieved by adding a file like
core/src/validateMachineConfig.ts
, probably with implementation, on the lines of the following snippetLet me know if you think it might be of value. Also, would love to contribute towards this too!
Beta Was this translation helpful? Give feedback.
All reactions