rsthn / rose-ext-shield
Shield Validation Extension
Installs: 635
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:rose-extension
Requires
- dev-master
- v2.0.15
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-11-12 20:24:21 UTC
README
Shield provides a set of functions to validate data in a very robust way.
Installation
composer require rsthn/rose-ext-shield
Functions
(shield:method-required
<method...>)
Ensures the request was made using the specified method(s) or fails with 405/@messages.method_not_allowed.
(shield:body-required
[false|true|content-type...])
Ensures the request's content-type is one of the specified types. Fails with 422/@messages.request_body_missing if there is no
request body, or with 422/@messages.invalid_content_type if the content-type is not valid. If no content type is provided then
it is assumed to be application/json
. Use value true
to allow any content type.
(shield:body-min-size
<min-size>)
Ensures the request's body is at least the specified number of bytes. Fails with 422/@messages.request_body_too_small if not.
(shield:body-max-size
<max-size>)
Ensures the request's body does not exceed the specified number of bytes. Fails with 422/@messages.request_body_too_large when so.
(shield:field
<output-name> [rules...])
Returns a field descriptor.
(shield:field username required true min-length 3 max-length 20 ) ; (descriptor)
(shield:type
<type-name> <rules...>)
Registers a type validation descriptor to be used by name in the type
rules.
(shield:type "email" max-length 256 pattern email )
(shield:begin
)
Begins quiet validation mode. All validation errors will be accumulated, and should later be retrieved by calling shield:end
,
this is useful to batch multiple validation blocks at once.
(shield:end
[automatic=true])
Ends quiet validation mode, if there are any errors and automatic
is set to true
(default), then Wind::R_VALIDATION_ERROR will
be thrown, otherwise, the error map will just be returned.
(shield:validate
[output-var] <field-descriptors...>)
Validates the fields in the gateway request. Any error will be reported, and the validated object will be available in the
global context or in the output variable (if provided) when validation succeeds.
NOTE: This is a legacy function, use the replacement shield:validate-data
when possible.
(shield:validate form (shield:field name required true max-length 8 ) (shield:field email required true pattern email ) )
(shield:model
<data-descriptors...>)
Creates and returns a new validation model to be re-used later with shield:validate-data
.
(shield:model (object "username" (string) "password" (string) "email" (rules required true pattern email ) ) ) ; model_45ef12
(shield:validate-data
<output-var> <input-object> <model|data-descriptors...>)
Validates the fields in the input data using the specified data rules. If any validation error occurs an exception will be thrown. If the data is successfully validated it will be available in the output variable.