Hexadecimal Color Rule
Validate a Hexadecimal Color Code
114k Downloads / Month
Open Source MIT License
114k Downloads / Month
Open Source MIT License
public Intervention\Validation\Rules\HexColor::__construct(?int $length = null)
The field under validation must be a valid hexadecimal color code.
Optional length as integer to check only for shorthand (3 characters) or full hexadecimal (6 characters) form.
use Intervention\Validation\Rules\HexColor;
$validator = Validator::make($request->all(), [
'attribute-key' => new HexColor(3),
]);
Edit