Metarules
Metarules are rules for describing more complex rules: nested objects, lists and alternatives. Errors of nested rules are returned in the same shape as the data.
nested_objectDescribes validation rules for a nested object.{ nested_object: { … } }FORMAT_ERRORvariable_objectDescribes validation rules for a field that can contain different kinds of objects. The value of the selector field (product_type in the example) chooses the set of rules.{ variable_object: ['type', { … }] }FORMAT_ERRORlist_ofDescribes validation rules for a list. The rules are applied to every element.{ list_of: 'positive_integer' }FORMAT_ERRORlist_of_objectsDescribes validation rules for a list of objects. The rules are applied to every element.{ list_of_objects: { … } }FORMAT_ERRORlist_of_different_objectsDescribes validation rules for a list of different objects. For every element, the value of the selector field chooses the set of rules, like in variable_object.{ list_of_different_objects: ['type', { … }] }FORMAT_ERRORorTakes several sets of rules and applies them one after another until one of them succeeds.{ or: ['email', 'positive_integer'] }no errors