Download the PHP package tobento/app-validation without Composer
On this page you can find all versions of the php package tobento/app-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tobento/app-validation
More information about tobento/app-validation
Files in tobento/app-validation
Package app-validation
Short Description App validation support.
License MIT
Homepage https://www.tobento.ch
Informations about the package app-validation
App Validation
Validation support for the app.
Table of Contents
- Getting Started
- Requirements
- Documentation
- App
- Validator Boot
- Validate Data
- Adding Rules
- Message Translation
- Http Validation
- Http Requirements
- Using Validation Request
- Writing Request Validation
- Http Validation Error Handler Boot
- Live Validation
- Credits
Getting Started
Add the latest version of the app validation project running this command.
Requirements
- PHP 8.0 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
Validator Boot
The validator boot does the following:
- installs validator translation files
- validator and rules interfaces implementation
Validate Data
You can validate data using the . You can access the validator in several ways:
Check out the Validation Service - Validating section learn more about validating data in general.
Using the app
Using autowiring
You can also request the in any class resolved by the app.
Adding Rules
The Default Rules are available by default. You may add more rules by the following way:
You may check out the Rules section to learn more about adding rules.
Message Translation
Simply, install the App Translation bundle and boot the :
Messages will be translated based on the Configured Translator Locale.
By default, the Default Rules error messages are translated in and .
Check out the Add Translation section to learn how to add translations.
Make sure you define the resource name for rule error messages as configured on the Message Translator Modifier. The Message Parameter Translator Modifier uses the as resource name.
Http Validation
Http Requirements
The following app example shows the minimum requirements for the http validation.
First, install the App Http bundle:
In addition, you may install the App View bundle for view support:
Next, make sure the following boots are defined:
Using Validation Request
You may use the for validating the request input.
By default, a will be thrown if validation fails. The exception will be handled by the if booted. See Http Validation Error Handler Boot.
You may check out the following links for its documentation:
Manually handling validation
Http Validation Error Handler Boot
The http error handler boot does the following:
- handles exceptions.
When the incoming HTTP request is expecting a JSON response, the error handler will return a 422 Unprocessable Entity HTTP response with the following format:
Otherwise, the error handler will return a redirect response by using the defined parameter from the or if not defined using the uri:
Furthermore, you may create a custom Error Handler or add an Error Handler With A Higher Priority of as defined on the .
Live Validation
In progress...
Credits
- Tobias Strub
- All Contributors
All versions of app-validation with dependencies
tobento/app Version ^1.0
tobento/app-migration Version ^1.0
tobento/service-validation Version ^1.0
tobento/service-message Version ^1.0.1