module Clear::Model::HasValidation

Included Modules

Direct including types

Defined in:

clear/model/modules/has_validation.cr

Instance Method Summary

Instance Method Detail

def add_error(column, reason) #

Add validation error related to a specific column


[View source]
def add_error(reason) #

Add validation error not related to a specific column


[View source]
def clear_errors #

Clear the errors log (if any) of the model and return itself


[View source]
def error? #

Return true if saving has been declined because of validation issues. The error list can be found by calling Clear::Model#errors


[View source]
def errors : Array(Error) #

List of errors raised during validation, in case the model hasn't been saved properly.


[View source]
def print_errors #

Print the errors in string. Useful for debugging or simple error handling.


[View source]
def valid! #

Check whether the model is valid. If not, raise InvalidModelError. Return the model itself


[View source]
def valid? #

Return true if the model


[View source]
def validate #

This method is called whenever #valid? or save is called. By default, #validate is empty and must be overriden by your own validation code.


[View source]