module Hathor::Validation
Included Modules
- Hathor::Validation::AbsenceValidator
- Hathor::Validation::AllowBlankBreaker
- Hathor::Validation::EmailValidator
- Hathor::Validation::MaxValidator
- Hathor::Validation::MinValidator
- Hathor::Validation::PresenceValidator
Direct including types
Defined in:
breakers/allow_blank.crvalidation.cr
validators/absence.cr
validators/email.cr
validators/max.cr
validators/min.cr
validators/presence.cr
Constant Summary
-
BREAKER_VALIDATORS =
{allow_blank => {:method => break_on_absence}} of Nil => Nil
-
validations wich will stop other validations on !success!, for example: 'allow_blank'
-
VALIDATORS =
{presence => {:method => validate_presence, :key => "not_present"}, absence => {:method => validate_absence, :key => "not_absent"}, min => {:method => validate_minimum, :key => "lt_min"}, max => {:method => validate_maximum, :key => "gt_max"}, email => {:method => validate_email, :key => "invalid_email"}} of Nil => Nil
-
simple validations
Macro Summary
- __process_validation
-
register_validation(option, method, key)
register a validator module option - name of option used in validates method - method defined in validator key - error string to add if validation fails
-
register_validation_breaker(option, method)
register a validator module as breaker option - name of option used in validates method - method defined in validator
- validate
-
validates(field_name, **validation_options)
TODO would be nice to check within macros if validations are applyable to field type
- validates_elements_of(field_name, **validation_options)
Instance methods inherited from module Hathor::Validation::AllowBlankBreaker
break_on_absence(value : String | Array, option, **options)break_on_absence(value : Nil, option, **options)
break_on_absence(value, option, **options) break_on_absence
Instance methods inherited from module Hathor::Validation::EmailValidator
validate_email(value : String, option, **options)validate_email(value, option, **options) validate_email
Instance methods inherited from module Hathor::Validation::MaxValidator
validate_maximum(value : String | Array, option, **options)validate_maximum(value : Int | Float, option, **options)
validate_maximum(value, option, **options) validate_maximum
Instance methods inherited from module Hathor::Validation::MinValidator
validate_minimum(value : String | Array, option, **options)validate_minimum(value : Int | Float, option, **options)
validate_minimum(value : Nil, option, **options)
validate_minimum(value, option, **options) validate_minimum
Instance methods inherited from module Hathor::Validation::AbsenceValidator
validate_absence(value : String | Array, option, **options)validate_absence(value : Nil, option, **options)
validate_absence(value, option, **options) validate_absence
Instance methods inherited from module Hathor::Validation::PresenceValidator
validate_presence(value : String | Array, option, **options)validate_presence(value : Nil, option, **options)
validate_presence(value, option, **options) validate_presence
Macro Detail
register a validator module option - name of option used in validates method - method defined in validator key - error string to add if validation fails
register a validator module as breaker option - name of option used in validates method - method defined in validator
TODO would be nice to check within macros if validations are applyable to field type