mirror of
https://github.com/Respect/Validation.git
synced 2024-06-04 23:02:16 +02:00
Make "HexRgbColor" rule case-insensitive
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
444f105ea6
commit
1809e9f4c4
|
@ -6,6 +6,7 @@ Validates weather the input is a hex RGB color or not.
|
|||
|
||||
```php
|
||||
v::hexRgbColor()->validate('#FFFAAA'); // true
|
||||
v::hexRgbColor()->validate('#ff6600'); // true
|
||||
v::hexRgbColor()->validate('123123'); // true
|
||||
v::hexRgbColor()->validate('FCD'); // true
|
||||
```
|
||||
|
@ -18,6 +19,7 @@ v::hexRgbColor()->validate('FCD'); // true
|
|||
|
||||
Version | Description
|
||||
--------|-------------
|
||||
2.1.0 | Allow hex RGB colors to be case-insensitive
|
||||
2.0.0 | Allow hex RGB colors with 3 integers
|
||||
0.7.0 | Created
|
||||
|
||||
|
|
|
@ -23,6 +23,6 @@ final class HexRgbColor extends AbstractEnvelope
|
|||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new Regex('/^#?([0-9A-F]{3}|[0-9A-F]{6})$/'));
|
||||
parent::__construct(new Regex('/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,11 +37,14 @@ final class HexRgbColorTest extends RuleTestCase
|
|||
return [
|
||||
[$sut, '#000'],
|
||||
[$sut, '#00000F'],
|
||||
[$sut, '#00000f'],
|
||||
[$sut, '#123'],
|
||||
[$sut, '#123456'],
|
||||
[$sut, '#FFFFFF'],
|
||||
[$sut, '#ffffff'],
|
||||
[$sut, '123123'],
|
||||
[$sut, 'FFFFFF'],
|
||||
[$sut, 'ffffff'],
|
||||
[$sut, 443],
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue