Class: Pakyow::Validator::Result
- Inherits:
-
Object
- Object
- Pakyow::Validator::Result
- Defined in:
- lib/pakyow/validator.rb
Instance Method Summary collapse
- #error(validation, options) ⇒ Object
-
#initialize(key) ⇒ Result
constructor
A new instance of Result.
- #messages(type: :default) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(key) ⇒ Result
Returns a new instance of Result.
11 12 13 14 |
# File 'lib/pakyow/validator.rb', line 11 def initialize(key) @key = key @errors = [] end |
Instance Method Details
#error(validation, options) ⇒ Object
16 17 18 |
# File 'lib/pakyow/validator.rb', line 16 def error(validation, ) @errors << [validation, ] end |
#messages(type: :default) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/pakyow/validator.rb', line 24 def (type: :default) @errors.map { |validation, | Verifier.( ([:message] || validation.(**)), type: type, key: @key ) } end |
#valid? ⇒ Boolean
20 21 22 |
# File 'lib/pakyow/validator.rb', line 20 def valid? @errors.empty? end |