PHPackages                             jessesoeteman/validate-get-post-input - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. jessesoeteman/validate-get-post-input

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

jessesoeteman/validate-get-post-input
=====================================

This php class lets you validate a POST or GET input.

v1.3.1(3y ago)2315MITPHPPHP &gt;=8.0

Since Jan 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/JesseSoeteman/ValidateGetPostInput)[ Packagist](https://packagist.org/packages/jessesoeteman/validate-get-post-input)[ RSS](/packages/jessesoeteman-validate-get-post-input/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

ValidateGetPostInput
====================

[](#validategetpostinput)

This php library should help you validate your input from GET and POST requests.
It will also help you sanitize your input.

requirements
------------

[](#requirements)

The following requirements are needed to use this library:

- PHP 8.0 or higher
- Composer

Installation
------------

[](#installation)

To install this library, run the following command in your terminal:

```
composer require jessesoeteman/validate-get-post-input
```

Make sure you have composer installed on your system. And to include the autoloader in your code.

```
require __DIR__ . '/vendor/autoload.php';
```

How to use ValidateGetPostInput?
--------------------------------

[](#how-to-use-validategetpostinput)

### Basic usage

[](#basic-usage)

Below are a couple of examples with prebuilt classes these make it easier to use the library.
The prebuilt classes are:

- [ValidateBoolean](#validateboolean)
- [ValidateNumber](#validatenumber)
- [ValidateFloat](#validatefloat)
- [ValidateText](#validatetext)
- [ValidateJSON](#validatejson)
- [ValidateID](#validateid)
- [ValidateEmail](#validateemail)
- [ValidateVarchar255](#validatevarchar255)
- [ValidateVarchar255Regex](#validatevarchar255regex)
- [ValidateDate](#validatedate)

### General information

[](#general-information)

The prebuilt classes except for the [ValidateVarchar255Regex](#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

[](#validateboolean)

```
use ValidateGetPostInput\Prebuilt\ValidateBoolean;

$_boolean = new ValidateBoolean("boolean"); // The name of the input, so $_GET["boolean"] or $_POST["boolean"]
$errors += $_boolean->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$boolean = $_boolean->getValue(); // This returns the value of the input.
```

If you dont want to make a parameter required, you can set the second parameter to false.

```
use ValidateGetPostInput\Prebuilt\ValidateBoolean;

$_boolean = new ValidateBoolean("boolean", false);
$errors += $_boolean->validate();
$boolean = $_boolean->getValue();
```

### ValidateNumber

[](#validatenumber)

```
use ValidateGetPostInput\Prebuilt\ValidateNumber;

$_number = new ValidateNumber("number"); // The name of the input, so $_GET["number"] or $_POST["number"]
$errors += $_number->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$number = $_number->getValue(); // This returns the value of the input.
```

### ValidateFloat

[](#validatefloat)

```
use ValidateGetPostInput\Prebuilt\ValidateFloat;

$_float = new ValidateFloat("float"); // The name of the input, so $_GET["float"] or $_POST["float"]
$errors += $_float->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$float = $_float->getValue(); // This returns the value of the input.
```

### ValidateText

[](#validatetext)

```
use ValidateGetPostInput\Prebuilt\ValidateText;

$_text = new ValidateText("text"); // The name of the input, so $_GET["text"] or $_POST["text"]
$errors += $_text->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$text = $_text->getValue(); // This returns the value of the input.
```

### ValidateJSON

[](#validatejson)

```
use ValidateGetPostInput\Prebuilt\ValidateJSON;

$_json = new ValidateJSON("json"); // The name of the input, so $_GET["json"] or $_POST["json"]
$errors += $_json->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$json = $_json->getValue(); // This returns the value of the input.
```

### ValidateID

[](#validateid)

The minimum value of the id is 1, and the maximum value is 2147483647.

```
use ValidateGetPostInput\Prebuilt\ValidateID;

$_id = new ValidateID("id"); // The name of the input, so $_GET["id"] or $_POST["id"]
$errors += $_id->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$id = $_id->getValue(); // This returns the value of the input.
```

### ValidateEmail

[](#validateemail)

```
use ValidateGetPostInput\Prebuilt\ValidateEmail;

$_email = new ValidateEmail("email"); // The name of the input, so $_GET["email"] or $_POST["email"]
$errors[] = $_email->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$email = $_email->getValue(); // This returns the value of the input.
```

### ValidateVarchar255

[](#validatevarchar255)

```
use ValidateGetPostInput\Prebuilt\ValidateVarchar255;

$_varchar255 = new ValidateVarchar255("varchar255"); // The name of the input, so $_GET["varchar255"] or $_POST["varchar255"]
$errors += $_varchar255->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$varchar255 = $_varchar255->getValue(); // This returns the value of the input.
```

### ValidateVarchar255Regex

[](#validatevarchar255regex)

```
use ValidateGetPostInput\Prebuilt\ValidateVarchar255Regex;

$_varchar255Regex = new ValidateVarchar255Regex("varchar255Regex", "/^[a-zA-Z0-9]+$/"); // The name of the input, so $_GET["varchar255Regex"] or $_POST["varchar255Regex"], the second parameter is the regex, the third parameter is if the input is required, default is true.
$errors += $_varchar255Regex->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$varchar255Regex = $_varchar255Regex->getValue(); // This returns the value of the input.
```

### ValidateDate

[](#validatedate)

The default date format is 'Y-m-d H:i:s', but you can change it with the fourth parameter.

```
use ValidateGetPostInput\Prebuilt\ValidateDate;
use ValidateGetPostInput\Statics\DateFormat;

$_date = new ValidateDate("date", true, DateFormat::YYYY_MM_DD); // The name of the input, so $_GET["date"] or $_POST["date"], the second parameter is if the input is required, default is true. The third parameter is the date format, default is 'Y-m-d H:i:s'.
$errors += $_date->validate(); // This returns an array with errors if there are any, returns an empty array if there are no errors.
$date = $_date->getValue(); // This returns the value of the input.
```

How to use ValidateMultiple?
----------------------------

[](#how-to-use-validatemultiple)

ValidateMultiple lets you validate multiple inputs at once.

```
use ValidateGetPostInput\ValidateMultiple;

use ValidateGetPostInput\Prebuilt\ValidateID;
use ValidateGetPostInput\Prebuilt\ValidateVarchar255;
use ValidateGetPostInput\Prebuilt\ValidateText;
```

Be sure to use a try catch block, because if there is an error, it will throw an exception.

```
try {
    $validations = new ValidateMultiple([
        new ValidateID("id"),
        new ValidateVarchar255("name"),
        new ValidateText("description"),
        new ValidateVarchar255("link")
    ]);
} catch (Exception $e) {
    $erros += $e->getMessage();
    // Do something with the errors
    exit();
}
$error += $validations->validate();
// Check if the validation faid
if (count($errors) > 0) {
    // Do something with the errors
    exit();
}
// Get the validated data as an key value array
$inputData = $validations->getValues();
```

License
-------

[](#license)

This project is licensed under the [MIT](license)License - see the [LICENSE](license) file for details

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

4

Last Release

1206d ago

PHP version history (2 changes)v1.1PHP &gt;=5.6.0

v1.3PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/84839290081b74165d24ccd9f9555020b1423db5acb855d9df20a2d1dd15188f?d=identicon)[JesseSoeteman](/maintainers/JesseSoeteman)

---

Top Contributors

[![JesseSoeteman](https://avatars.githubusercontent.com/u/67485119?v=4)](https://github.com/JesseSoeteman "JesseSoeteman (107 commits)")

---

Tags

php

### Embed Badge

![Health badge](/badges/jessesoeteman-validate-get-post-input/health.svg)

```
[![Health](https://phpackages.com/badges/jessesoeteman-validate-get-post-input/health.svg)](https://phpackages.com/packages/jessesoeteman-validate-get-post-input)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
