Requests are designed by contract in order to enforce correctness and type-safe definitions
Every HTTP request message has a specific form:
An HTTP message is either a request from a client to a server or a response from a server to a client.
Requests are designed by contract in order to enforce correctness. What this means is that requests are strictly typed and can have preconditions. With this concept.
The Request provides concise, type-safe, and self-validated request objects.
Self-documented request objects.
Type-safe requests and parameters
Enables Focused and effective testing.
JSON body requests render object instances.
Azu::Contract are provided by tight integration with the Schema shard
Example Use:
Requests can be initialized are initialized in the background and property is available to the Endpoint of the same name of the request as the camel case.
Requests can be initialized from JSON, YAML, and the standard initializes method new.
When the built-in validation helpers are not enough for your needs, you can write your own validators or validation methods as you prefer.
Custom validators are simple classes that inherit from Schema::Validator
. These classes must implement the valid?
method which takes a record as an argument and performs the validation on it. The custom validator is called using the valid?
or validate!
method.
To enable the custom validator to your structs or classes by simply defining the use ConfirmPasswordValidator
Instance Method
Description
validate
A macro to define validation rules for your request
valid?
Validates the request object and returns true or false
validate!
Validates and raises an exception when invalid
rules
returns a list of rules to be applied on validation
params
Request params. See Params
to_json
A JSON representation of the request
to_yaml
A YAML representation of the request