mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Consoloidate duplicate regex strings in money() validation.
This commit is contained in:
parent
396c025529
commit
f65e481ebf
1 changed files with 3 additions and 2 deletions
|
@ -472,10 +472,11 @@ class Validation {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public static function money($check, $symbolPosition = 'left') {
|
public static function money($check, $symbolPosition = 'left') {
|
||||||
|
$money = '(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?';
|
||||||
if ($symbolPosition == 'right') {
|
if ($symbolPosition == 'right') {
|
||||||
$regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
|
$regex = '/^' . $money . '(?<!\x{00a2})\p{Sc}?$/u';
|
||||||
} else {
|
} else {
|
||||||
$regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
|
$regex = '/^(?!\x{00a2})\p{Sc}?' . $money . '$/u';
|
||||||
}
|
}
|
||||||
return self::_check($check, $regex);
|
return self::_check($check, $regex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue