Class: Coradoc::Validation::Rule
- Inherits:
-
Object
- Object
- Coradoc::Validation::Rule
- Defined in:
- lib/coradoc/validation.rb
Overview
Base class for validation rules
Direct Known Subclasses
Coradoc::Validation::Rules::Count, Coradoc::Validation::Rules::Custom, Coradoc::Validation::Rules::Format, Coradoc::Validation::Rules::Length, Coradoc::Validation::Rules::Required, Coradoc::Validation::Rules::Type
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(name, **options) ⇒ Rule
constructor
A new instance of Rule.
- #validate(element, context = {}) ⇒ Object
Constructor Details
#initialize(name, **options) ⇒ Rule
Returns a new instance of Rule.
180 181 182 183 |
# File 'lib/coradoc/validation.rb', line 180 def initialize(name, **) @name = name @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
178 179 180 |
# File 'lib/coradoc/validation.rb', line 178 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
178 179 180 |
# File 'lib/coradoc/validation.rb', line 178 def @options end |
Instance Method Details
#validate(element, context = {}) ⇒ Object
185 186 187 |
# File 'lib/coradoc/validation.rb', line 185 def validate(element, context = {}) raise NotImplementedError, 'Subclasses must implement #validate' end |