module Marten::Core::Validation::Callbacks

Overview

Provides the ability to define validation callbacks.

This module provides the ability to define callbacks that are executed before and / or after running validation rules for the validated objects. Two hooks are enabled by the use of this module: before_validation callbacks are executed before running validation rules while after_validation callbacks are executed after running them.

Direct including types

Defined in:

marten/core/validation/callbacks.cr

Macro Summary

Macro Detail

macro after_validation(*names) #

Allows to do define callbacks that are called after running the registered validation rules.

Either one or multiple validation methods can be specified:

class MyClass
  include Marten::Core::Validation

  after_validation(:callback_1)
  after_validation(:callback_2, :callback_3)
end

[View source]
macro before_validation(*names) #

Allows to do define callbacks that are called before running the registered validation rules.

Either one or multiple validation methods can be specified:

class MyClass
  include Marten::Core::Validation

  before_validation(:callback_1)
  before_validation(:callback_2, :callback_3)
end

[View source]