module Kemal::FormValidator

Overview

Kemal::FormValidator is a module that contains a collection of different form field validators.

Validators in Kemal::FormValidator:

Custom validators can be created by making a class inherit from Kemal::FormValidator::Validator and implement a custom def validate(field : Kemal::Form::Field). validate should raise a Kemal::Form::ValidationError to signal that a validation error has occured.

class CustomValidator < Kemal::FormValidator::Validator
  def validate(field : Kemal::Form::Field)
    # code ....
    #
    # raise a Kemal::Form::ValidationError to signal that
    # a validation error has occured
  end
end

Defined in:

kemal-form/validators.cr