Module: Rosebud::Validations
- Defined in:
- lib/rosebud/validations.rb,
lib/rosebud/validations/type_validator.rb,
lib/rosebud/validations/regex_validator.rb,
lib/rosebud/validations/presence_validator.rb
Defined Under Namespace
Classes: PresenceValidator, RegexValidator, TypeValidator
Class Attribute Summary collapse
-
.validators ⇒ Object
readonly
Returns the value of attribute validators.
Class Method Summary collapse
Class Attribute Details
.validators ⇒ Object (readonly)
Returns the value of attribute validators.
6 7 8 |
# File 'lib/rosebud/validations.rb', line 6 def validators @validators end |
Class Method Details
.register_validator!(name, klass) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rosebud/validations.rb', line 9 def self.register_validator!(name, klass) raise(ArgumentError, 'Validation class type expected to be a subclass of Rosebud::Validator...') unless klass.ancestors.include?(Validator) raise(NotImplementedError, 'Validator expected validate_param to be implemented...') unless klass.instance_methods.include?(:validate_param) name = name.to_sym Errawr.register!(name) @validators[name] = klass end |