Skip to content

Instantly share code, notes, and snippets.

@renalpha
Last active May 28, 2019 15:09
Show Gist options
  • Save renalpha/576404a10564d83c35e837ec72d4e15d to your computer and use it in GitHub Desktop.
Save renalpha/576404a10564d83c35e837ec72d4e15d to your computer and use it in GitHub Desktop.
Regex Multiple names validation
<?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