abstract class Quartz::Verifiers::RuntimeChecker
- Quartz::Verifiers::RuntimeChecker
- Reference
- Object
Overview
A simple base class that can be used along with Verifiable#check_with
class MyModel
include Verifiable
check_with MyVerifier
end
class MyVerifier < RuntimeChecker
def check(model)
if some_complex_logic
model.errors.add(:base, "This model is invalid")
end
end
private def some_complex_logic
# ...
end
end
Any class that inherits from RuntimeChecker
must implement a
method called #check
which accepts a model.
class MyModel
include Verifiable
check_with MyVerifier
end
class MyVerifier < RuntimeChecker
def check(model)
model # => The model instance being validated
end
end
To cause a verification error, you must add to the model's errors directly from within the verifiers message.
class MyVerifier < RuntimeChecker
def check(model)
model.errors.add :attr1, "This is some custom error message"
model.errors.add :attr2, "This is some complex validation"
# etc...
end
end
Note that the verifier is initialized only once for the whole application life cycle, and not on each verification run.
Direct Known Subclasses
Defined in:
quartz/verifiers/checker.crConstructors
Instance Method Summary
-
#check(model) : Bool
Override this method in subclasses with verification logic, adding errors to the models errors array where necessary.
- #contexts : Array(Symbol)?
-
#strict? : Bool
Whether this verifier will cause a
StrictVerificationFailed
error to be raised when#check
returns false.
Instance methods inherited from class Reference
==(other : Quartz::Any)
==
Instance methods inherited from class Object
===(other : Quartz::Any)
===
Constructor Detail
Instance Method Detail
Override this method in subclasses with verification logic, adding errors to the models errors array where necessary.
Whether this verifier will cause a StrictVerificationFailed
error to
be raised when #check
returns false.