class Schematics::SchemaBuilder(T)

Overview

Builder for creating schemas with additional constraints

Defined in:

schema.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def add_validator(message : String, &block : T -> Bool) #

Add a custom validator


[View source]
def build : Schema(T) #

Build the final schema


[View source]
def max_length(length : Int32) forall T #

For strings: set maximum length


[View source]
def max_size(size : Int32) forall T #

For arrays: set maximum size


[View source]
def max_value(value : T) forall T #

For numbers: set maximum value


[View source]
def min_length(length : Int32) forall T #

For strings: set minimum length


[View source]
def min_size(size : Int32) forall T #

For arrays: set minimum size


[View source]
def min_value(value : T) forall T #

For numbers: set minimum value


[View source]