respect-validation/library/Rules/HexRgbColor.php

25 lines
516 B
PHP
Raw Normal View History

2014-07-16 10:02:26 +02:00
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
2015-06-08 16:47:14 +02:00
namespace Respect\Validation\Rules;
2014-07-16 10:02:26 +02:00
/**
* Validates whether the input is a hex RGB color or not.
*
* @author Davide Pastore <pasdavide@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class HexRgbColor extends AbstractEnvelope
2014-07-16 10:02:26 +02:00
{
public function __construct()
2014-07-16 10:02:26 +02:00
{
parent::__construct(new Regex('/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i'));
2014-07-16 10:02:26 +02:00
}
}