Download the PHP package jessesoeteman/validate-get-post-input without Composer
On this page you can find all versions of the php package jessesoeteman/validate-get-post-input. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jessesoeteman/validate-get-post-input
More information about jessesoeteman/validate-get-post-input
Files in jessesoeteman/validate-get-post-input
Package validate-get-post-input
Short Description This php class lets you validate a POST or GET input.
License MIT
Informations about the package validate-get-post-input
ValidateGetPostInput
This php library should help you validate your input from GET and POST requests.
It will also help you sanitize your input.
requirements
The following requirements are needed to use this library:
- PHP 8.0 or higher
- Composer
Installation
To install this library, run the following command in your terminal:
Make sure you have composer installed on your system. And to include the autoloader in your code.
How to use ValidateGetPostInput?
Basic usage
Below are a couple of examples with prebuilt classes these make it easier to use the library.
The prebuilt classes are:
- ValidateBoolean
- ValidateNumber
- ValidateFloat
- ValidateText
- ValidateJSON
- ValidateID
- ValidateEmail
- ValidateVarchar255
- ValidateVarchar255Regex
- ValidateDate
General information
The prebuilt classes except for the ValidateVarchar255Regex class, will will have the following parameters as the first parameters in the constructor:
- The name of the input, so if you want to validate $_GET["username"] you would use "username" as the first parameter.
- The request type, default is RequestType::GET, you can use RequestType::POST to validate $_POST["username"].
- If the input is required, default is true.
ValidateBoolean
If you dont want to make a parameter required, you can set the second parameter to false.
ValidateNumber
ValidateFloat
ValidateText
ValidateJSON
ValidateID
The minimum value of the id is 1, and the maximum value is 2147483647.
ValidateEmail
ValidateVarchar255
ValidateVarchar255Regex
ValidateDate
The default date format is 'Y-m-d H:i:s', but you can change it with the fourth parameter.
How to use ValidateMultiple?
ValidateMultiple lets you validate multiple inputs at once.
Be sure to use a try catch block, because if there is an error, it will throw an exception.
License
This project is licensed under the MIT License - see the LICENSE file for details