Class: Lotus::Validations::Attribute Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/validations/attribute.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A validable attribute

Since:

  • 0.1.0

Constant Summary collapse

CONFIRMATION_TEMPLATE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Attribute naming convention for “confirmation” validation

See Also:

  • #confirmation

Since:

  • 0.2.0

'%{name}_confirmation'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, name, value, validations, errors) ⇒ Attribute

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Instantiate an attribute

Parameters:

  • attributes (Hash)

    a set of attributes and values coming from the input

  • name (Symbol)

    the name of the attribute

  • value (Object, nil)

    the value coming from the input

  • validations (Hash)

    a set of validation rules

Since:

  • 0.2.0



37
38
39
40
41
42
43
# File 'lib/lotus/validations/attribute.rb', line 37

def initialize(attributes, name, value, validations, errors)
  @attributes  = attributes
  @name        = name
  @value       = value
  @validations = validations
  @errors      = errors
end

Instance Attribute Details

#valueObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.0



65
66
67
# File 'lib/lotus/validations/attribute.rb', line 65

def value
  @value
end

Instance Method Details

#validateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.0



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/lotus/validations/attribute.rb', line 47

def validate
  presence
  acceptance

  return if skip?

  format
  inclusion
  exclusion
  size
  confirmation
  nested

  @errors
end