class Tarot::Schema
- Tarot::Schema
- Reference
- Object
Defined in:
tarot/schema.crtarot/schema/converters.cr
tarot/schema/errors.cr
tarot/schema/validators.cr
Constant Summary
-
KEYS =
{} of Nil => Nil -
RULES =
[] of Nil -
VERSION =
"0.2.0"
Constructors
Class Method Summary
- .from_json(value : JSON::Any, hint = nil, coercive = false)
- .from_json(parser : JSON::PullParser)
- .from_json(string : String)
- .from_json(any)
- .from_json(**tuple)
Macro Summary
- _build_to_json
- _build_to_tuple
- _build_validate
-
factory(on, map, fallback = false)
Generate a factory for inherited schema, which bind the value of the field
onto a specific subclass defined by the tuple: - field(name_and_type, converter = nil, key = nil, hint = nil, emit_null = false, coercive = false)
- rule(field, message, &block)
- schema(name, optional = false, type = :record)
Instance Method Summary
- #[](field : String)
- #[]?(field : String)
- #add_error(key : String, error : String)
- #errors : Hash(String, Array(String)) | Nil
- #errors? : Hash(String, Array(String)) | Nil | Nil
- #field_valid?(field)
- #raw_fields : JSON::Any
- #valid!
- #valid?
- #validate_nested(root : String, value)
Constructor Detail
Class Method Detail
Macro Detail
macro factory(on, map, fallback = false)
#
Generate a factory for inherited schema, which bind the value of the
field on to a specific subclass defined by the tuple:
Event.factory("type", {"google": GoogleEvent, "facebook" : FacebookEvent})
Therefore, when using Event.from_json(json),
this will create GoogleEvent or FacebookEvent.
macro field(name_and_type, converter = nil, key = nil, hint = nil, emit_null = false, coercive = false)
#