Skip to content

Instantly share code, notes, and snippets.

@arcanedev-maroc
Forked from elena-kolevska/validators.php
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save arcanedev-maroc/9392834 to your computer and use it in GitHub Desktop.

Select an option

Save arcanedev-maroc/9392834 to your computer and use it in GitHub Desktop.
<?php
/* app/validators.php */
Validator::extend('alpha_spaces', function($attribute, $value)
{
return preg_match('/^[\pL\s]+$/u', $value);
});
/* lang/en/validation.php */
/* ------------------------------------------------------------------------------------------------
| Custom Validation Messages
| ------------------------------------------------------------------------------------------------
*/
"alpha_spaces" => "Le :attribute ne peut contenir que des lettres et des espaces.",
/*
* add the validators.php file in start/global.php: require app_path().'/validators.php'
* and use it as usual: $rules = array('name' => 'required|alpha_spaces',);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment