Skip to content

Commit

Permalink
Merge pull request #8 from LSFLK/nizar-dev
Browse files Browse the repository at this point in the history
validate charset in strict mode
  • Loading branch information
mohamednizar authored Jun 16, 2020
2 parents 96bd017 + 51907bd commit 75aec58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/UniqueUid.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function isValidUniqueId(string $token)
$length = strlen($token);

// validate the character set
$valid = preg_match("/^[" . self::$charSet . "]/", $token);
$valid = preg_match("/^[" . self::$charSet . "]+$/", $token);
if (!$valid) {
return false;
}elseif(is_numeric($token)){
Expand Down
4 changes: 4 additions & 0 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function testInvalid(){
$this->assertEquals(false,$valid5);
$valid6 = $this->userId::isValidUniqueId('A0401157841844');
$this->assertEquals(false,$valid6);
$valid6 = $this->userId::isValidUniqueId('B0216157494076');
$this->assertEquals(false,$valid6);
$valid7 = $this->userId::isValidUniqueId('D216157494076');
$this->assertEquals(false,$valid7);
}

public function testArrayInput() {
Expand Down

0 comments on commit 75aec58

Please sign in to comment.