Skip to content
Snippets Groups Projects
Commit 770fe4e0 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge branch 'develop' into develop-next

parents 9efd196f 6986e6f7
No related branches found
No related tags found
No related merge requests found
......@@ -177,7 +177,7 @@ class Validator {
function is_username($username, &$error='') {
if (strlen($username)<2)
$error = 'At least two (2) characters';
elseif (!preg_match('/^[\p{L}._-]+$/u', $username))
elseif (!preg_match('/^[\p{L}\d._-]+$/u', $username))
$error = 'Username contains invalid characters';
return $error == '';
}
......
<?php
require_once INCLUDE_DIR.'class.validator.php';
class TestValidation extends Test {
var $name = "Validation checks";
function testValidUsernames() {
// Ascii
$this->assert(Validator::is_username('jared'));
$this->assert(Validator::is_username('jared12'));
// Unicode
$this->assert(Validator::is_username('järed'));
$this->assert(Validator::is_username('järed12'));
$this->assert(Validator::is_username('中国期刊全文数据'));
// Non-letters
$this->assert(!Validator::is_username('j®red'));
}
}
return 'TestValidation';
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment