Last active
May 28, 2019 15:09
-
-
Save renalpha/576404a10564d83c35e837ec72d4e15d to your computer and use it in GitHub Desktop.
Regex Multiple names validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Expression | |
$expression = '/^([_\p{Lu}\p{Lt}][_\p{Nd}\p{Ll}\p{Lm}\p{Lo} ',-."]+)+$/u'; | |
$rules = [ | |
'full_name' => 'required|regex:' . $expression, | |
'first_name' => 'required|regex:' . $expression, | |
'last_name' => 'required|regex:' . $expression | |
]; | |
// Allows all names https://www.w3.org/International/questions/qa-personal-names | |
// Except Chinese characters... | |
// Allows names such as Jan Hendriks Willemsen | |
// Allows names such as Zoë Jans Janssen | |
// Allows names such as D'arcy d,o-s santos | |
// Does not allow JAN HENDRIK WILLEMSEN | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment