matthewjwhite / crystal-skull

:skull: Highly-configurable, telnet-compatible, text-based RPG
MIT License
0 stars 0 forks source link

Add YAML validation #18

Closed matthewjwhite closed 3 years ago

matthewjwhite commented 3 years ago

As the configuration grows, some sort of validation is needed to ensure that all required fields are present before starting the game. Careful attention to the configuration can't always be depended on. Right now, there is a lack of validation to ensure all required fields are present - a YAML schema would solve this problem.

https://github.com/23andMe/Yamale/ seems like a really neat project for this purpose. I'd prefer to avoid updating both the schema and associated config. loader (example) every time a new attribute is added to a configuration object, though.

matthewjwhite commented 3 years ago

See this PR's description for remaining stuff to ensure total validation: https://github.com/matthewjwhite/crystal-skull/pull/21.

matthewjwhite commented 3 years ago

Added Yamale to handle structural validation - implying content as well by this, to the point that we're verifying basic attributes such as length, etc. Filled in the gaps that Yamale doesn't handle using extra logic in the Config constructor.

matthewjwhite commented 3 years ago

I wonder if DB documents should also be validated when loading them into memory as objects, since **kwargs craziness is used to load them as well... Probably not a huge necessity since nothing touches the DB but this. Perhaps the easiest/most valuable thing at this point would be to confirm that the DB user's class and location map still exist in the configuration.