Module: ActiveModel

Defined in:
lib/can_has_validations/validators/array_validator.rb

Overview

validates each member element of an array attribute

by default will allow only the first error per validator, regardless of how many elements might fail validation. this improves performance as well as averting a large number of repeating error messages. use multiple_errors: true on :array or a single sub-validator to enable the full set of errors. this is potentially useful if each error message will vary based upon the array element’s contents.

usage:

validates :tags,
  array: {
    format: /\A[^aeiou]*\z/,
    length: 5..10
  }

validates :permissions,
  array: {
    multiple_errors: true,
    format: /\A[^aeiou]*\z/
  }

Defined Under Namespace

Modules: Validations