Nicer API for repeat validation
itamarst opened this issue · 2 comments
itamarst commented
A common pattern is to use the same schema to validate multiple documents. In the current API, this requires a bunch of work involving the innards of the implementation:
- Create a lexer.
- Create a parser.
- For each document to be parsed, create a validator, since validators are single-shot.
A nicer API would be something like:
let cddl_schema = CDDLSchema::from_slice(my_schema_bytes);
for document in documents {
cdd_schema.validate(document)?
}
anweiss commented
Agreed. I was mostly focused on implementation and less so on the API. Will clean this up.