mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 07:15:45 +01:00
25 lines
488 B
PHP
25 lines
488 B
PHP
<?php
|
|
namespace Respect\Validation\Rules;
|
|
|
|
use Respect\Validation\Validator as v;
|
|
|
|
class HexRgbColor extends Xdigit
|
|
{
|
|
public function validate($input)
|
|
{
|
|
if (!is_string($input)) {
|
|
return false;
|
|
}
|
|
|
|
if (0 === strpos($input, '#')) {
|
|
$input = substr($input, 1);
|
|
}
|
|
|
|
$length = strlen($input);
|
|
if ($length != 3 && $length != 6) {
|
|
return false;
|
|
}
|
|
|
|
return parent::validate($input);
|
|
}
|
|
}
|