/**
* Validate some data.
*
* @param string|array $fields
* @param string|array $rules
* @return bool
*/
function validate($fields, $rules)
{
if (! is_array($fields)) {
$fields = ['default' => $fields];
}
if (! is_array($rules)) {
$rules = ['default' => $rules];
}
return Validator::make($fields, $rules)->passes();
}
All available validation rules in Laravel can be used.
Example:
validate('20150230', 'date'); // returns false
validate('20150228', 'date'); // returns true
validate('[email protected]', 'email'); // returns true