Module: Veto::Validator::ClassMethods
- Defined in:
- lib/veto/validator.rb
Instance Method Summary collapse
- #valid?(*args) ⇒ Boolean
- #validate(*args) ⇒ Object
-
#validate!(*args) ⇒ Object
Raises exception if entity is invalid.
-
#validate_with(*validator_set) ⇒ Object
Used to add a validator, or set of validators, to the validators list.
- #validates(*args) ⇒ Object
-
#validators ⇒ Array
Memoizes a flat list of internal validator instances that will perform validations on the assigned entity.
- #with_options(*args, &block) ⇒ Object
Instance Method Details
#valid?(*args) ⇒ Boolean
57 58 59 |
# File 'lib/veto/validator.rb', line 57 def valid? *args new(*args).valid? end |
#validate(*args) ⇒ Object
20 21 22 |
# File 'lib/veto/validator.rb', line 20 def validate *args builder.validate(*args) end |
#validate!(*args) ⇒ Object
Raises exception if entity is invalid
69 70 71 |
# File 'lib/veto/validator.rb', line 69 def validate! *args new(*args).validate! end |
#validate_with(*validator_set) ⇒ Object
Used to add a validator, or set of validators, to the validators list. Generally used by the ‘validates` and `validate` methods internally.
34 35 36 |
# File 'lib/veto/validator.rb', line 34 def validate_with *validator_set validators.concat validator_set.flatten end |
#validates(*args) ⇒ Object
16 17 18 |
# File 'lib/veto/validator.rb', line 16 def validates *args builder.validates(*args) end |
#validators ⇒ Array
Memoizes a flat list of internal validator instances that will perform validations on the assigned entity.
48 49 50 |
# File 'lib/veto/validator.rb', line 48 def validators @validators ||= [] end |
#with_options(*args, &block) ⇒ Object
12 13 14 |
# File 'lib/veto/validator.rb', line 12 def *args, &block builder.(*args, &block) end |