hex
Validates that a field contains a hexadecimal number.
Options
| Option | Type | Default | Description |
|---|---|---|---|
message | string | locale default | Custom error message |
Playground
Valid values
| Value | Notes |
|---|---|
"FF5733" | Valid hex digits |
"0a1b2c" | Lowercase hex |
"0" | Single digit |
Invalid values
| Value | Reason |
|---|---|
"GG5733" | G is not a hex digit |
"#FF5733" | Hash prefix is not allowed |
Notes
- Empty string (
"") always returnsvalid: true. Combine withnotEmptyto require a value. - For CSS color validation (with
#prefix,rgb(), etc.), usecolorinstead.