PHPackages                             bouncers-book/bouncers-book - 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. bouncers-book/bouncers-book

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

bouncers-book/bouncers-book
===========================

PHP form validator

0.5.0(11y ago)0631MITPHPPHP &gt;=5.3.0

Since Aug 12Pushed 11y ago1 watchersCompare

[ Source](https://github.com/al-codepone/bouncers-book)[ Packagist](https://packagist.org/packages/bouncers-book/bouncers-book)[ Docs](https://github.com/al-codepone/bouncers-book)[ RSS](/packages/bouncers-book-bouncers-book/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersions (2)Used By (1)

Bouncer's Book
==============

[](#bouncers-book)

Bouncer's Book is a PHP form validator.

Documentation
-------------

[](#documentation)

This [README](https://github.com/al-codepone/bouncers-book/blob/master/README.md)is currently the only documentation.

Requirements
------------

[](#requirements)

**PHP 5.3** or higher and [Composer](https://getcomposer.org/). The [tests](https://github.com/al-codepone/bouncers-book/tree/master/test)require [Corn Wand](https://github.com/al-codepone/corn-wand).

Source Code
-----------

[](#source-code)

The [project](https://github.com/al-codepone/bouncers-book) is on GitHub. The source code is [one class](https://github.com/al-codepone/bouncers-book/blob/master/src/bbook/FormValidator.php).

Tests
-----

[](#tests)

All the tests are in the [test directory](https://github.com/al-codepone/bouncers-book/tree/master/test). Each PHP script in the top level test directory is a separate test. You need to run `composer install` in the test directory before running any of the tests. Tests 1-3 test the first, second and third constructor parameters respectively. Test 4 tests the `more()` method.

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

[](#installation)

Install using composer:

```
{
    "require": {
        "bouncers-book/bouncers-book": "0.5.0",
    }
}
```

Basic Usage
-----------

[](#basic-usage)

Set up a form validator class:

```
namespace silver\validator;

class Validator1 extends \bbook\FormValidator {
    public function __construct() {

        //list all the form inputs
        parent::__construct(array(
            'input1',
            'input2'));
    }

    //validate form inputs with validate_ methods
    //return null if valid
    protected function validate_input1($value) {
        if(!preg_match('/^[a-z0-9]{1,10}$/i', $value)) {
            return 'Input 1 must be 1-10 characters; letters and numbers only';
        }
    }

    //validate method for input2
    protected function validate_input2($value) {
        if(strlen($value) < 6) {
            return 'Input 2 must be 6 or more characters';
        }
    }
}
```

Validate `$_POST` with `validate()`:

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

$validator = new silver\validator\Validator1();

if(list($input_values, $errors) = $validator->validate()) {
    $content = $errors

        //re-display form if there is an error
        ? form1($input_values, $errors)

        //no errors, process form data
        : c\pre(print_r($input_values, true));
}
else {

    //form not submitted, first time user arrives at website
    $content = form1($validator->values());
    $autofocus = c\focus('input1');
}

include 'src/silver/html/template.php';
```

Optional Inputs
---------------

[](#optional-inputs)

Use the second constructor parameter to specify which submitted inputs are optional:

```
namespace silver\validator;

class Validator2 extends \bbook\FormValidator {
    public function __construct() {
        parent::__construct(

            //list form inputs and default values
            array(
                'input1',
                'pizzas' => array()),

            //list optional inputs, pizzas is checkboxes
            array('pizzas'));
    }

    protected function validate_input1($value) {
        if(!preg_match('/^[a-z0-9]{1,10}$/i', $value)) {
            return 'Input 1 must be 1-10 characters; letters and numbers only';
        }
    }

    protected function validate_pizzas($value) {
        if(count($value) != 2) {
            return 'Choose 2 types of pizza';
        }
    }
}
```

Validate Any Data
-----------------

[](#validate-any-data)

Use the third constructor parameter to specify the data to validate:

```
namespace silver\validator;

class Validator3 extends \bbook\FormValidator {
    public function __construct() {
        parent::__construct(

            //list form inputs
            array(
                'input1',
                'input2'),

            //which are optional? none
            array(),

            //validate this data instead of $_POST
            array(
                'input1' => 'Fred?',
                'input2' => '123456'));
    }

    protected function validate_input1($value) {
        if(!preg_match('/^[a-z0-9]{1,10}$/i', $value)) {
            return 'Input 1 must be 1-10 characters; letters and numbers only';
        }
    }

    protected function validate_input2($value) {
        if(strlen($value) < 6) {
            return 'Input 2 must be 6 or more characters';
        }
    }
}
```

Validate More
-------------

[](#validate-more)

Use `more()` to validate more than one value at a time:

```
namespace silver\validator;

class Validator4 extends \bbook\FormValidator {
    public function __construct() {
        parent::__construct(array(
            'input1',
            'input2'));
    }

    protected function validate_input1($value) {
        if(trim($value) == '') {
            return 'Please enter a value for Input 1';
        }
    }

    protected function validate_input2($value) {
        if(trim($value) == '') {
            return 'Please enter a value for Input 2';
        }
    }

    protected function more($values) {
        if(trim($values['input1']) != '' &&
            trim($values['input2']) != '' &&
            $values['input1'] != $values['input2'])
        {
            return 'Input 1 and Input 2 must be the same';
        }
    }
}
```

LICENSE
-------

[](#license)

MIT

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

4291d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dde0ea39d89e43216fff0c3b80d61ffd6293e9632d5b6f2f20ca48847cba7894?d=identicon)[hadramoo](/maintainers/hadramoo)

---

Top Contributors

[![ferg1e](https://avatars.githubusercontent.com/u/2236096?v=4)](https://github.com/ferg1e "ferg1e (15 commits)")

---

Tags

validatorformForms

### Embed Badge

![Health badge](/badges/bouncers-book-bouncers-book/health.svg)

```
[![Health](https://phpackages.com/badges/bouncers-book-bouncers-book/health.svg)](https://phpackages.com/packages/bouncers-book-bouncers-book)
```

###  Alternatives

[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[barbieswimcrew/zip-code-validator

Constraint class for international zipcode validation

772.3M](/packages/barbieswimcrew-zip-code-validator)[form-manager/form-manager

PHP-HTML form manager

16041.0k7](/packages/form-manager-form-manager)

PHPackages © 2026

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