Module: SecID::Validatable::ClassMethods
- Defined in:
- lib/sec_id/concerns/validatable.rb
Overview
Class methods added when Validatable is included.
Instance Method Summary collapse
-
#error_class_for(code) ⇒ Class
Maps an error code symbol to its corresponding exception class.
- #valid?(id) ⇒ Boolean
-
#validate(id) ⇒ Base
Validates the identifier and returns the instance (with errors cached).
-
#validate!(id) ⇒ Base
Validates the identifier, raising an exception if invalid.
Instance Method Details
#error_class_for(code) ⇒ Class
Maps an error code symbol to its corresponding exception class.
52 53 54 |
# File 'lib/sec_id/concerns/validatable.rb', line 52 def error_class_for(code) ERROR_MAP.fetch(code, InvalidFormatError) end |
#valid?(id) ⇒ Boolean
27 28 29 |
# File 'lib/sec_id/concerns/validatable.rb', line 27 def valid?(id) new(id).valid? end |
#validate(id) ⇒ Base
Validates the identifier and returns the instance (with errors cached).
35 36 37 |
# File 'lib/sec_id/concerns/validatable.rb', line 35 def validate(id) new(id).validate end |
#validate!(id) ⇒ Base
Validates the identifier, raising an exception if invalid.
44 45 46 |
# File 'lib/sec_id/concerns/validatable.rb', line 44 def validate!(id) new(id).validate! end |