abstract class Jennifer::Validations::Validator
- Jennifer::Validations::Validator
- Reference
- Object
Overview
Base validation class.
Take into account that Validator implement singleton pattern. This means that only one instance of each validator will be created cross the application. As a result #validate method should be pure.
To implement own validator just inherit and define #validate class, which accepts record as a first argument
class CustomValidator < Jennifer::Validations::Validator
def validate(record, field, message = nil)
if record.attribute(field) == "invalid"
record.errors.add(field, message || "blank")
end
end
end
Extended Modules
- Jennifer::Validations::Validator::ClassMethods
Direct Known Subclasses
- Jennifer::Validations::Absence
- Jennifer::Validations::Acceptance
- Jennifer::Validations::Confirmation
- Jennifer::Validations::Exclusion
- Jennifer::Validations::Format
- Jennifer::Validations::Inclusion
- Jennifer::Validations::Length
- Jennifer::Validations::Numericality
- Jennifer::Validations::Presence
- Jennifer::Validations::Uniqueness
Defined in:
jennifer/validations/validator.crInstance Method Summary
- #blank_validation(record, field, value, allow_blank)
-
#validate(record, **opts)
Validates given record based on args and opts.