Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MatTheCat committed Feb 11, 2023
1 parent 2075838 commit 6b86297
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@ class NoSuspiciousCharacters extends Constraint
*/
public const CHECK_HIDDEN_OVERLAY = 256;

/** @see https://unicode.org/reports/tr39/#ascii_only */
public const RESTRICTION_LEVEL_ASCII = 268435456;

/** @see https://unicode.org/reports/tr39/#single_script */
public const RESTRICTION_LEVEL_SINGLE_SCRIPT = 536870912;

/** @see https://unicode.org/reports/tr39/#highly_restrictive */
public const RESTRICTION_LEVEL_HIGH = 805306368;

/** @see https://unicode.org/reports/tr39/#moderately_restrictive */
public const RESTRICTION_LEVEL_MODERATE = 1073741824;

/** @see https://unicode.org/reports/tr39/#minimally_restrictive */
public const RESTRICTION_LEVEL_MINIMAL = 1342177280;

/** @see https://unicode.org/reports/tr39/#unrestricted */
public const RESTRICTION_LEVEL_NONE = 1610612736;

public string $restrictionLevelMessage = 'Restriction level check failed.';
Expand Down Expand Up @@ -102,7 +113,7 @@ public function __construct(
mixed $payload = null
) {
if (!class_exists(\Spoofchecker::class)) {
throw new LogicException('The intl extension is required to use the NotSuspicious constraint.');
throw new LogicException('The intl extension is required to use the NoSuspiciousCharacters constraint.');
}

parent::__construct($options, $groups, $payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public function validate(mixed $value, Constraint $constraint)
throw new UnexpectedValueException($value, 'string');
}

$value = (string) $value;
if ('' === $value) {
if ('' === $value = (string) $value) {
return;
}

Expand Down

0 comments on commit 6b86297

Please sign in to comment.