Hexadecimal Color Rule

Validate a Hexadecimal Color Code

134k Downloads / Month

Open Source MIT License

You are viewing the documentation for Intervention Validation Version 3. This version has reached end of life (EOL). Please consider upgrading to version 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