Module: ActiveModel

Defined in:
lib/can_has_validations/validators/array_validator.rb,
lib/can_has_validations/validators/hash_keys_validator.rb,
lib/can_has_validations/validators/hash_values_validator.rb

Overview

validates each value of a hash attribute

by default only allows the first error per validator, regardless of how many values fail validation. this improves performance and avoids a bunch of repeating error messages. use ‘multiple_errors: true` on :hash_values or a single sub-validator to enable the full set of errors. this is potentially useful if each error message will vary based upon each hash value.

the :if, :unless, and :on conditionals are not supported on sub-validators, but do work as normal on the :hash_values validator itself.

usage:

validates :subjects,
  hash_values: {
    length: 3..100,
    # multiple_errors: true
  }

Defined Under Namespace

Modules: Validations