for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Divergence package.
*
* (c) Henry Paradiz <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Divergence\Helpers;
class Validate
{
public static function string($string, array $options = [])
$options = array_merge([
'minlength' => 1,
'maxlength' => false,
], $options);
return !empty($string) && is_string($string)
&& (strlen($string) >= $options['minlength'])
&& (($options['maxlength'] == false) || (strlen($string) <= $options['maxlength']));
}
public static function number($number, array $options = [])
'min' => false,
'max' => false,
return is_numeric($number)
&& (($options['min'] === false) || ($number >= $options['min']))
&& (($options['max'] === false) || ($number <= $options['max']));
public static function email($email, array $options = [])
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
return true;
} else {
return false;