Skip to content

Each

  • Each(rule: AbstractRule)

Validates whether each value in the input is valid according to another rule.

release_dates = {
    'validation': '2010-01-01',
    'template'  : '2011-01-01',
    'relational': '2011-02-05',
}
v.each(v.dateTime()).validate(release_dates.values())  # true

You can also validate array keys combining this rule with Call:

v.call('values', v.each(v.stringType())).validate(release_dates)  # true

This rule will not validate values that are not iterable (don't have attribute __iter__), to have a more detailed error message, add Iterable to your chain, for example.

If the input is empty list then this rule will consider the value as valid, please use NotEmpty if required:

v.each(v.dateTime()).validate([])  # true
v.notEmpty().each(v.dateTime()).validate([])  # false

Categorization

  • Arrays
  • Nesting

Changelog

Version Description
1.0.0 Created

See also: