Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Add uppercase and lowercase validators #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Classes/Domain/Validator/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ protected function validateMustInclude($value, $validationSettingList)
}
break;

// value must include uppercase letter
case 'uppercase':
if (!$this->stringContainsUpperCharacter($value)) {
$isValid = false;
}
break;

// value must include lowercase letter
case 'lowercase':
if (!$this->stringContainsLowerCharacter($value)) {
$isValid = false;
}
break;

default:
}
}
Expand Down Expand Up @@ -315,6 +329,28 @@ protected function stringContainsSpaceCharacter($value)
return (strpos($value, ' ') !== false);
}

/**
* String contains space character?
*
* @param string $value
* @return bool
*/
protected function stringContainsUpperCharacter($value)
{
return (strlen(preg_replace('/[A-Z]/', '', $value)) !== strlen($value));
}

/**
* String contains space character?
*
* @param string $value
* @return bool
*/
protected function stringContainsLowerCharacter($value)
{
return (strlen(preg_replace('/[a-z]/', '', $value)) !== strlen($value));
}

/**
* Validation for checking if values are in a given list
*
Expand Down