Open MarkOates opened 11 months ago
Most importantly the validator class is designed to have very user-friendly error messages that include the the data that didn't match validation. It would also implicitly know the class and method which so it could be included in the error message.
Also consider introducing custom quintessence specifications so an end user could add in the "validate" element in their own projects without it having to become a major part of the standard quintessence schema.
You could have a standard validator with functions and remove the need for defining a class. For example:
validate:
- not_nullptr(a_pointer)
- vector_contains(tokens, "who")
- min_token_count(tokens, 2)
- tokens_not_empty(tokens)
A class would be implicitly included:
class StandardValicator
that has the methods std::vector<std::string> vector_contains(...)
..., etc.
You may need to validate in stages
validate_in_groups:
- validations:
- not_nullptr(a_pointer)
- validations:
- vector_contains(a_pointer->tokens, "who")
- min_token_count(tokens, 2)
- tokens_not_empty(tokens)
in quintessence:
would produce: