Hexadecimal Color Rule

Validate a Hexadecimal Color Code

132k Downloads / Month

Open Source MIT License

You are viewing the documentation for Intervention Validation 3, this version has reached end of life (EOL). Please consider upgrading to version 4.

public Intervention\Validation\Rules\HexColor::__construct(?int $length = null)

The field under validation must be a valid hexadecimal color code.

Parameters

length (optional)

Optional length as integer to check only for shorthand (3 characters) or full hexadecimal (6 characters) form.

Example

use Intervention\Validation\Rules\HexColor;

$validator = Validator::make($request->all(), [
    'attribute-key' => new HexColor(3),
]);
Edit