class
Amber::Schema::Definition
- Amber::Schema::Definition
- Reference
- Object
Direct Known Subclasses
- Amber::Schema::RequestSchema
- Amber::Schema::ResponseSchema
- BookXMLSchema
- FormDataExample::ApplicationFormSchema
- FormDataExample::DocumentUploadSchema
- FormDataExample::OrderFormSchema
- FormDataExample::UserProfileSchema
- FormDataExample::UserRegistrationSchema
Defined in:
amber/schema/definition.crConstructors
Class Method Summary
-
.conditionals : Array(ConditionalGroup)
Get all conditionals for introspection
- .field_names : Array(String)
-
.has_conditionals? : Bool
Check if schema has conditionals
-
.has_field?(name : String) : Bool
Class methods for introspection
- .required_field_names : Array(String)
- .uses_body_params? : Bool
- .uses_header_params? : Bool
- .uses_path_params? : Bool
- .uses_query_params? : Bool
Macro Summary
-
content_type(*types)
Define supported content types
-
field(name, type, **options)
Define a field in the schema
- from_body
- from_header
- from_path
-
from_query
Parameter source blocks
-
nested(name, schema_class)
Define a nested schema field
-
requires_one_of(*fields)
Helper macro for requiring exactly one of a set of fields
-
requires_together(*fields)
Helper macro for defining multiple fields that must be present together
-
validate(method_name = nil, &block)
Add a custom validator
-
validates_to(success_type, failure_type = ValidationError)
Define success and failure types
-
when_field(field, value)
Define conditional field requirements
-
when_present(field)
Define fields that must be present together
Instance Method Summary
- #errors : Array(Amber::Schema::Error)
-
#parse : LegacyResult
Parse incoming data and return a result
-
#raw_data : Hash(String, JSON::Any)
Instance variables
-
#to_h : Hash(String, JSON::Any)
Convert validated data to hash
-
#validate : LegacyResult
Main validation method - returns legacy Result for backward compatibility
-
#validate_typed : Success(Hash(String, JSON::Any)) | Failure(Hash(String, JSON::Any))
New validation method that returns typed Result
Constructor Detail
Class Method Detail
Macro Detail
Helper macro for defining multiple fields that must be present together
Instance Method Detail
Main validation method - returns legacy Result for backward compatibility