Module: Attestor::Validations
- Extended by:
- ClassMethods
- Included in:
- Policy
- Defined in:
- lib/attestor/validations.rb,
lib/attestor/validations/context.rb,
lib/attestor/validations/message.rb,
lib/attestor/validations/reporter.rb,
lib/attestor/validations/delegator.rb,
lib/attestor/validations/validator.rb,
lib/attestor/validations/validators.rb
Overview
API for objects to be validated
Defined Under Namespace
Modules: ClassMethods, Reporter Classes: Context, Delegator, Message, Validator, Validators
Class Method Summary collapse
Instance Method Summary collapse
-
#invalid(name, options = {}) ⇒ Object
Raises InvalidError with a corresponding message.
-
#validate(context = :all) ⇒ undefined
Calls all validators for given context and return validation results.
-
#validate!(context = :all) ⇒ undefined
Calls all validators for given context.
Methods included from ClassMethods
validates, validations, validators
Class Method Details
.included(klass) ⇒ Object
138 139 140 |
# File 'lib/attestor/validations.rb', line 138 def self.included(klass) klass.instance_eval { extend ClassMethods } end |
Instance Method Details
#invalid(name, options = {}) ⇒ String #invalid(name) ⇒ String
Raises InvalidError with a corresponding message
48 49 50 51 |
# File 'lib/attestor/validations.rb', line 48 def invalid(name, = {}) = Message.new(name, self, ) fail InvalidError.new self, end |
#validate(context = :all) ⇒ undefined
Calls all validators for given context and return validation results
25 26 27 |
# File 'lib/attestor/validations.rb', line 25 def validate(context = :all) self.class.validators.set(context).validate self end |
#validate!(context = :all) ⇒ undefined
Calls all validators for given context
16 17 18 |
# File 'lib/attestor/validations.rb', line 16 def validate!(context = :all) self.class.validators.set(context).validate! self end |