-
Notifications
You must be signed in to change notification settings - Fork 36
Description
YAML 1.2 defines support for schemas, which, in turn, specify how you'd parse the data.
See https://yaml.org/spec/1.2.2/#chapter-10-recommended-schemas
It would be nice to have a high-level support for those schemas at the parser level.
I'm thinking something like load::<Failsafe>(mystr) (where we have a type-level distinction between the schemas) or load(mystr, schemas::FAILSAFE) (where we have no type-level distinction between the schemas - cause they're a set of tags and means to resolve them maybe it'd work). I wouldn't want an enum-based API load(mystr, YamlSchema::Core) unless it was accompanied with a way to pass your own schema as in load::<MySchema>(mystr, MySchema::default()) - so, the former would really be load::<YamlSchema>(mystr, YamlSchema::Core).
Refs:
- In JS world, this exists: https://github.com/eemeli/yaml; they have support for schemas https://eemeli.org/yaml/#schema-options - although a but crude, since there's no support for custom schemas