Smallest unit of data validation.
A Constraint is a generic type that can be used to validate any type that conforms to garlic::ViewLayer.
This type cannot be inherited and it does not have public constructors. The proper way to create a Constraint is to use Constraint::make() or its shorthand make_constraint().
If needed, one can define an uninitialized Constraint using Constraint::empty() but this Constraint should not be passed to any other object as it is uninitialized and can lead to crashes or at least undefined behaviors.
- Note
- You should think of Constraint as a shared pointer to a context data that can be used to instantiate test and quick_test methods when needed. Thus, copying a Constraint does not really deep copy its inside, it creates a new pointer that holds onto the inner context, much like a shared pointer. In fact it does use a shared pointer inside.
auto regex_constriant = garlic::make_constraint<garlic::regex_tag>("\\d");
auto copy = regex_constraint;
©.context() == ®ex_constraint.context();