module Marten::Core::Validation

Overview

Provides validation to objects.

Direct including types

Defined in:

marten/core/validation.cr
marten/core/validation/callbacks.cr
marten/core/validation/error.cr
marten/core/validation/error_set.cr

Macro Summary

Instance Method Summary

Macro Detail

macro validate(*names) #

Registers validation methods.


[View source]

Instance Method Detail

def errors : ErrorSet #

Returns the error set containing the errors generated during a validation.


[View source]
def invalid?(context : Nil | String | Symbol = nil) #

Returns a boolean indicating whether the object is invalid.

An optional context can be specified using the context argument. When this option is used, additional validation rules that explicitly require a specific context might run.


[View source]
def valid?(context : Nil | String | Symbol = nil) #

Returns a boolean indicating whether the object is valid.

An optional context can be specified using the context argument. When this option is used, additional validation rules that explicitly require a specific context might run.


[View source]
def validate #

Allows to run custom validations for the considered object.

By default this method is empty and does nothing. It should be overridden in the specific class at hand in order to implement custom validation logics.


[View source]