Class: Violated::UniqueValidator
- Inherits:
-
Object
- Object
- Violated::UniqueValidator
- Defined in:
- lib/violated/validators/unique_validator.rb
Instance Method Summary collapse
-
#initialize(_, unique_check) ⇒ UniqueValidator
constructor
A new instance of UniqueValidator.
- #reason ⇒ Object
- #valid?(value) ⇒ Boolean
Constructor Details
#initialize(_, unique_check) ⇒ UniqueValidator
Returns a new instance of UniqueValidator.
6 7 8 |
# File 'lib/violated/validators/unique_validator.rb', line 6 def initialize(_, unique_check) @unique_check = unique_check end |
Instance Method Details
#reason ⇒ Object
10 11 12 |
# File 'lib/violated/validators/unique_validator.rb', line 10 def reason :duplicate end |
#valid?(value) ⇒ Boolean
14 15 16 |
# File 'lib/violated/validators/unique_validator.rb', line 14 def valid?(value) !@unique_check.call(value) end |