4b42459c by Jeff Balicki

error

1 parent 6d4998ff
......@@ -240,18 +240,18 @@ class Validation extends Common\Validation {
*/
protected function username($val) {
if (empty($val)) {
throw new Exception('<li>'.__('Username is blank', 'CBV_DOMAIN').'</li>');
throw new Exception('<li class="error-mess" data-error="username">'.__('Username is blank', 'CBV_DOMAIN').'</li>');
}
require_once(ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'registration.php');
if (!validate_username($val)) {
throw new Exception(
'<li>'.__('Username must be at least 4 characters, letters and numbers only', 'CBV_DOMAIN').'</li>'
'<li class="error" data-error="username">'.__('Username must be at least 4 characters, letters and numbers only', 'CBV_DOMAIN').'</li>'
);
}
if (username_exists($val)) {
throw new Exception('<li>'.__('Username already exists', 'CBV_DOMAIN').'</li>');
throw new Exception('<li class="error-mess" data-error="username">'.__('Username already exists', 'CBV_DOMAIN').'</li>');
}
}
......@@ -262,18 +262,18 @@ class Validation extends Common\Validation {
*/
protected function password($val) {
if (empty($val)) {
throw new Exception('<li>'.__('Password can not be blank', 'CBV_DOMAIN').'</li>');
throw new Exception('<li class="error-mess" data-error="password">'.__('Password can not be blank', 'CBV_DOMAIN').'</li>');
}
if (isset($val[PASS_MAX_LEN])) {
throw new Exception(
'<li>'.sprintf(__('Password can not be longer than %d characters.', 'CBV_DOMAIN'), PASS_MAX_LEN).'</li>'
'<li class="error-mess" data-error="password">'.sprintf(__('Password can not be longer than %d characters.', 'CBV_DOMAIN'), PASS_MAX_LEN).'</li>'
);
}
if (preg_match('/(\\\\|\\\'|"| )+/i', $val)) {
throw new Exception(
'<li>'.__('Password can not contain spaces, backslashes (\) or quotes', 'CBV_DOMAIN').'</li>'
'<li class="error-mess" data-error="password">'.__('Password can not contain spaces, backslashes (\) or quotes', 'CBV_DOMAIN').'</li>'
);
}
}
......@@ -284,11 +284,11 @@ class Validation extends Common\Validation {
*/
protected function email($val) {
if (!(boolean)filter_var($val, FILTER_VALIDATE_EMAIL)) {
throw new Exception('<li>'.__('Invalid email address', 'CBV_DOMAIN').'</li>');
throw new Exception('<li class="error-mess" data-error="email">'.__('Invalid email address', 'CBV_DOMAIN').'</li>');
}
if (false !== email_exists($val)) {
throw new Exception('<li>'.__('Email address already registered', 'CBV_DOMAIN').' </li > ');
throw new Exception('<li class="error-mess" data-error="email">'.__('Email address already registered', 'CBV_DOMAIN').' </li > ');
}
}
}
......