obf/validator

This package is abandoned and no longer maintained. The author suggests using the ubbs/php-lib-validator package instead.

The Opsbears Framework Validator Components

v1.1.1 2016-03-15 12:10 UTC

This package is not auto-updated.

Last update: 2019-02-20 18:23:20 UTC


README

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version License

Validators

Validators are classes that validate a value, but don't change it. They can either return true or false, indicating if a value is valid or not.

All validators should implement the iValidator interface:

interface iValidator {
	/**
	 * @return bool
	 */
	public function validate($value);
}

Some validators also come with static functions to make type checking easy.

This library comes with a basic set of validators:

Class Description
BooleanTypeValidator Does a strict or loose validation if a certain value is a boolean value.
BooleanValidator Only provides type checking for boolean

Filters

Filters not only validate data, but also process it. This helps with transforming the data in a way that is suitable for further processing. Filters should implement the iFilter interface:

interface iFilter {
	public function filter($value);
}

The filter module only provides a few basic filters, the rest are implemented in different namespaces:

Class Description
BooleanFilter Converts a value into a boolean. It respects the iBooleanConvertible interface from Foundation. Attempts to guess the value if a string is provided, based on the verbs submitted.
FloatFilter Converts a value to a float. It respects the iFloatConvertible interface from Foundation.
IntegerFilter Converts a value to an int. It respects the iIntegerConvertible interface from Foundation.
StringFilter Converts a value to a string. It respects the iStringConvertible interface from Foundation.