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.
59 60 61 |
# File 'lib/sec_id/concerns/validatable.rb', line 59 def error_class_for(code) ERROR_MAP.fetch(code, InvalidFormatError) end |
#valid?(id) ⇒ Boolean
34 35 36 |
# File 'lib/sec_id/concerns/validatable.rb', line 34 def valid?(id) new(id).valid? end |
#validate(id) ⇒ Base
Validates the identifier and returns the instance (with errors cached).
42 43 44 |
# File 'lib/sec_id/concerns/validatable.rb', line 42 def validate(id) new(id).validate end |
#validate!(id) ⇒ Base
Validates the identifier, raising an exception if invalid.
51 52 53 |
# File 'lib/sec_id/concerns/validatable.rb', line 51 def validate!(id) new(id).validate! end |