anweiss/cddl

Nicer API for repeat validation

itamarst opened this issue · 2 comments

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:

  1. Create a lexer.
  2. Create a parser.
  3. 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)?
}

Agreed. I was mostly focused on implementation and less so on the API. Will clean this up.

Cleaned up in #115. Please re-open for any additional API improvement requests.