Skip to content

Commit c88195b

Browse files
committed
Tighten rules, no API changes
1 parent bba1aca commit c88195b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Latest Stable Version](https://poser.pugx.org/f9webltd/laravel-validation-rules/v)](https://packagist.org/packages/f9webltd/laravel-validation-rules)
1+
[![Latest Stable Version](https://img.shields.io/packagist/v/f9webltd/laravel-validation-rules)](https://packagist.org/packages/f9webltd/laravel-validation-rules)
22
[![Scrutinizer coverage (GitHub/BitBucket)](https://img.shields.io/scrutinizer/coverage/g/f9webltd/laravel-validation-rules)]()
33
[![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/f9webltd/laravel-validation-rules)]()
44
[![Build Status](https://travis-ci.org/f9webltd/laravel-validation-rules.svg)](https://travis-ci.org/f9webltd/laravel-validation-rules)

src/Rules/NoWhitespace.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public function passes($attribute, $value): bool
1818
{
1919
$this->setAttribute($attribute);
2020

21+
if (null === $value) {
22+
return true;
23+
}
24+
2125
return preg_match('/\s/', $value) === 0;
2226
}
2327
}

src/Rules/Uppercase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use F9Web\ValidationRules\Rule;
88
use function is_string;
9+
use function mb_detect_encoding;
910
use function mb_strtoupper;
1011

1112
class Uppercase extends Rule
@@ -19,10 +20,10 @@ public function passes($attribute, $value): bool
1920
{
2021
$this->setAttribute($attribute);
2122

22-
if (! is_string($value)) {
23+
if (!is_string($value)) {
2324
return false;
2425
}
2526

26-
return mb_strtoupper($value, 'UTF-8') === (string) $value;
27+
return (string) $value === mb_strtoupper($value, mb_detect_encoding($value));
2728
}
2829
}

0 commit comments

Comments
 (0)