Skip to content

Parse Schema

To ensure that the request is valid and contains the expected data, Serinus provides the ParseSchema class that allows you to parse the query parameters, body, headers, cookies, and path parameters of the request.

The ParseSchema follows the Parse, don't validate principle, so if the parsing fails, the request is not valid and should be rejected.

The ParseSchema class has the following properties:

PropertyDescription
queryA schema that will be used to parse the query parameters.
bodyA schema that will be used to parse the body of the request.
headersA schema that will be used to parse the headers of the request.
sessionA schema that will be used to parse the cookies of the request.
paramsA schema that will be used to parse the path parameters of the request.
errorCustom exception that will be returned if the parsing fails.

All the schemas are optional and you can use them in any combination and the body schema is not an object schema, so you can use any schema that you want.

The ParseSchema class is abstract, so you can create your own implementation of the class and override the tryParse method to implement your own parsing logic.

Or you can use one of the provided implementations:

ImplementationDescriptionLink
AcanthisParseSchemaOfficial implementation of the ParseSchema class that uses the Acanthis library to parse the request.

Built with 💙 and Dart 🎯 | One of the 🐤 of Avesbox