Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

Commit

Permalink
UserName VO fix (between 2 and 32 chars)
Browse files Browse the repository at this point in the history
  • Loading branch information
chonsser committed Jun 15, 2017
1 parent 98ee5fe commit 509ccfc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Provider/ValueObject/UserName.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ public function __toString()
*/
private function guardUserName($user_name)
{
if(is_string($user_name) === false){
if (is_string($user_name) === false) {
throw new InvalidUserNameException("Username has to be a string");
}

$name_length = strlen($user_name);

if ($name_length > self::MAX_LENGTH) {
throw new InvalidUserNameException("Username must have less than 100 characters");
if ($name_length >= self::MAX_LENGTH) {
throw new InvalidUserNameException("Username must have less than " . self::MAX_LENGTH . " characters");
}

if ($name_length < self::MIN_LENGTH) {
throw new InvalidUserNameException("Username must have more than 2 characters");
if ($name_length <= self::MIN_LENGTH) {
throw new InvalidUserNameException("Username must have more than " . self::MIN_LENGTH . " characters");
}
}

Expand Down

0 comments on commit 509ccfc

Please sign in to comment.