Class: Lutaml::Model::ValidationRule

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/services/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute: nil, custom_method: nil, options: {}) ⇒ ValidationRule

Returns a new instance of ValidationRule.



8
9
10
11
12
13
14
15
16
# File 'lib/lutaml/model/services/validator.rb', line 8

def initialize(attribute: nil, custom_method: nil, options: {})
  if Utils.blank?(attribute) && Utils.blank?(custom_method)
    raise ArgumentError, "Missing attribute or custom method"
  end

  @attribute = attribute
  @options = options
  @custom_method = custom_method
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



6
7
8
# File 'lib/lutaml/model/services/validator.rb', line 6

def attribute
  @attribute
end

#custom_methodObject (readonly)

Returns the value of attribute custom_method.



6
7
8
# File 'lib/lutaml/model/services/validator.rb', line 6

def custom_method
  @custom_method
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/lutaml/model/services/validator.rb', line 6

def options
  @options
end

Instance Method Details

#custom?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/lutaml/model/services/validator.rb', line 18

def custom?
  Utils.present?(custom_method)
end

#has_options?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/lutaml/model/services/validator.rb', line 22

def has_options?
  options.is_a?(Hash)
end