Class: TypeValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/ansible/ruby/models/type_validator.rb

Overview

See LICENSE.txt for license

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ansible/ruby/models/type_validator.rb', line 6

def validate_each(record, attribute, value)
  # Don't worry about this case, different validator
  return if value.is_a? NilClass

  # We won't know until runtime what the type is
  return if value.is_a? Ansible::Ruby::Models::JinjaExpression

  failed = perform_validation(attribute, value)
  return unless failed

  failed = custom_error(value) if options[:message]
  record.errors[attribute] << failed
end