Class: EnvValidator::Rule
- Inherits:
-
Object
- Object
- EnvValidator::Rule
- Defined in:
- lib/env_validator/configuration.rb
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#custom_validator ⇒ Object
readonly
Returns the value of attribute custom_validator.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #has_constraints? ⇒ Boolean
- #has_custom_validator? ⇒ Boolean
- #has_default? ⇒ Boolean
- #has_format? ⇒ Boolean
-
#initialize(name, required: true, type: :string, default: nil, format: nil, description: nil, custom_validator: nil, **constraints) ⇒ Rule
constructor
A new instance of Rule.
- #optional? ⇒ Boolean
- #required? ⇒ Boolean
Constructor Details
#initialize(name, required: true, type: :string, default: nil, format: nil, description: nil, custom_validator: nil, **constraints) ⇒ Rule
Returns a new instance of Rule.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/env_validator/configuration.rb', line 7 def initialize(name, required: true, type: :string, default: nil, format: nil, description: nil, custom_validator: nil, **constraints) @name = name.to_sym @required = required @type = type @default = default @format = format @description = description @constraints = constraints @custom_validator = custom_validator end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def constraints @constraints end |
#custom_validator ⇒ Object (readonly)
Returns the value of attribute custom_validator.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def custom_validator @custom_validator end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def default @default end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def description @description end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def format @format end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/env_validator/configuration.rb', line 5 def type @type end |
Instance Method Details
#has_constraints? ⇒ Boolean
35 36 37 |
# File 'lib/env_validator/configuration.rb', line 35 def has_constraints? !@constraints.empty? end |
#has_custom_validator? ⇒ Boolean
39 40 41 |
# File 'lib/env_validator/configuration.rb', line 39 def has_custom_validator? !@custom_validator.nil? end |
#has_default? ⇒ Boolean
27 28 29 |
# File 'lib/env_validator/configuration.rb', line 27 def has_default? !@default.nil? end |
#has_format? ⇒ Boolean
31 32 33 |
# File 'lib/env_validator/configuration.rb', line 31 def has_format? !@format.nil? end |
#optional? ⇒ Boolean
23 24 25 |
# File 'lib/env_validator/configuration.rb', line 23 def optional? !@required end |
#required? ⇒ Boolean
19 20 21 |
# File 'lib/env_validator/configuration.rb', line 19 def required? @required end |