class

Alumna::Schema

Inherits Reference < Object

Constants

EMPTY_ERRORS = [] of FieldError

Constructors

build(strict : Bool = true, & : self -> ) : self
Source
new(strict : Bool = true)
Source

Instance methods

any(name, **opts)
Source
array(name : String, of : FieldType | Symbol, **opts)

For arrays of primitives

Source
array(name : String, **opts, &block : Schema -> )

For arrays of objects

Source
bool(name, **opts)
Source
bytes(name, **opts)
Source
field(name : String, type : FieldType | Symbol, required : Bool = true, nullable : Bool = false, unique : Bool = false, indexed : Bool = false, read_only : Bool = false, min_length : Int32 | Nil = nil, max_length : Int32 | Nil = nil, format : Symbol | String | Nil = nil, required_on : ServiceMethod | Symbol | Array(ServiceMethod | Symbol) | Nil = nil, sub_schema : Schema | Nil = nil, element_type : FieldType | Nil = nil, default : AnyData | Proc(AnyData) | Unprovided | Nil = Unprovided.new) : self
Source
fields
Source
find_field(path : String) : FieldDescriptor | Nil
Source
float(name, **opts)
Source
hash(name : String, **opts, &block : Schema -> )

For objects/hashes

Source
index(fields : Array(String) | String, unique : Bool = false) : self
Source
indexed_fields

Returns a flat list of all indexed fields (including nested hashes) and their dot-notation paths

Source
int(name, **opts)
Source
schema_indexes
Source
str(name, **opts)

--- Standard helpers ---

Source
strict
Source
time(name, **opts)
Source
unique_fields

Returns a flat list of all unique fields (including nested hashes) and their dot-notation paths

Source
validate(data : Hash(String, AnyData), method : ServiceMethod | Nil = nil) : Array(FieldError)
Source