src/OwpPasswordValidator.inc.php
static public function validate($value, $constraint)
    {
        self::$constraint = $constraint;

        $stringValue = (string) $value;
        if (function_exists('grapheme_strlen') && 'UTF-8' === self::$constraint->charset) {
            $length = grapheme_strlen($stringValue);
        } else if (function_exists('mb_strlen')) {
            $length = mb_strlen($stringValue,  self::$constraint->charset);
        } else {
            $length = strlen($stringValue);
        }

        if(self::$constraint->minLength > 0 && ($length < self::$constraint->minLength))
            self::addViolation(self::$tooShortMessage);
        if($constraint->maxLength > 0 && ($length > self::$constraint->maxLength))
            self::addViolation(self::$tooLongMessage);
        if($constraint->requireLetters && !preg_match('/\pL/', $stringValue))
            self::addViolation(self::$missingLettersMessage);
        if($constraint->requireCaseDiff && !preg_match('/(\p{Ll}+.*\p{Lu})|(\p{Lu}+.*\p{Ll})/', $stringValue))
            self::addViolation(self::$requireCaseDiffMessage);
        if($constraint->requireNumbers && !preg_match('/\pN/', $stringValue))
            self::addViolation(self::$missingNumbersMessage);
        if($constraint->requireNonAlphanumeric && ctype_alnum($stringValue))
            self::addViolation(self::$missingNonAlphanumericMessage);

        return (self::$violations ? self::$violations : false);

    }
static public function validate($value, $constraint)
    {
        self::$constraint = $constraint;

        $stringValue = (string) $value;
        if (function_exists('grapheme_strlen') && 'UTF-8' === self::$constraint->charset) {
            $length = grapheme_strlen($stringValue);
        } else if (function_exists('mb_strlen')) {
            $length = mb_strlen($stringValue,  self::$constraint->charset);
        } else {
            $length = strlen($stringValue);
        }

        if(self::$constraint->minLength > 0 && ($length < self::$constraint->minLength))
            self::addViolation(self::$tooShortMessage);
        if($constraint->maxLength > 0 && ($length > self::$constraint->maxLength))
            self::addViolation(self::$tooLongMessage);
        if($constraint->requireLetters && !preg_match('/\pL/', $stringValue))
            self::addViolation(self::$missingLettersMessage);
        if($constraint->requireCaseDiff && !preg_match('/(\p{Ll}+.*\p{Lu})|(\p{Lu}+.*\p{Ll})/', $stringValue))
            self::addViolation(self::$requireCaseDiffMessage);
        if($constraint->requireNumbers && !preg_match('/\pN/', $stringValue))
            self::addViolation(self::$missingNumbersMessage);
        if($constraint->requireNonAlphanumeric && ctype_alnum($stringValue))
            self::addViolation(self::$missingNonAlphanumericMessage);

        return (self::$violations ? self::$violations : false);

    }
validate

@method validate($value, $constraint)
@access public
@param  string $value      Password value
@param  object $constraint Constraints
@return mixed Violation array or false if no violations

@author  Brian Tafoya
@version 1.0