diff --git a/app/library/Validation/Validator/Alpha.php b/app/library/Validation/Validator/Alpha.php new file mode 100644 index 0000000..bcdacb1 --- /dev/null +++ b/app/library/Validation/Validator/Alpha.php @@ -0,0 +1,66 @@ +getOption('allowSpace', false); + + $charlist = '[:alpha:]'; + if ($allowSpace) { + $charlist .= '[:space:]'; + } + + $value = $validation->getValue($attribute); + + if (preg_match("/[^{$charlist}]/imu", $value)) { + + $label = $this->getOption('label'); + if (empty($label)) { + $label = $validation->getLabel($attribute); + } + + $message = $this->getOption('message'); + if (empty($message)) { + $message = $validation->getDefaultMessage('Alpha'); + } + + //var_dump($message);exit; + + $replace = [ ":field" => $label ]; + + $code = $this->getOption("code"); + if (is_array($code)) { + $code = $code[$attribute]; + } + + $message = str_replace(array_keys($replace), $replace, $message); + + $msg = new Message($message, $attribute, "Alpha", $code); + $validation->appendMessage($msg); + + return false; + } + + return true; + } +}