Wixel/GUMP — pull request #27 by headzoo (2013-12-09 19:49:30+00:00)
Title: Custom validators and filters API

Patch provides a modern API for adding custom validators and filters to GUMP without the need to extend the class. Two new static methods have been added to the GUMP class, which are documented in the README.

Example usage:

```php
require("gump.class.php");

// Create a custom validation rule named "is_object".
// The callback function receives three arguments:
// The field to validate, the values being validated, and any parameters used in the validation rule.
// It should return a boolean value indicating whether the value is valid.
GUMP::add_validator("is_object", function($field, $input, $param = NULL) {
return is_object($input[$field]);
});

// Create a custom filter named "upper".
// The callback function receives two arguments:
// The value to filter, and any parameters used in the filter rule. It should returned the filtered value.
GUMP::add_filter("upper", function($value, $params = NULL) {
return strtoupper($value);
});

```