ColorSchemaclass

new ColorSchema({ one = "color", title = "Color", value = "#000000", input = "color", max = 7, ...options }: ColorSchemaOptions)
ParamType
optionsColorSchemaOptions
Options for a ColorSchema. required
    .valuestring
Default hex value used when the input is undefined. Defaults to "#000000" readonly
    .maxnumber
Maximum allowed character length. Defaults to 7 readonly
    .case"upper"
"lower"
Force the result to "upper" or "lower" case. readonly
    .inputStringInputType
HTML <input /> type="" hint for downstream UIs. Defaults to "color" readonly
Return
ColorSchema
Schema that defines a valid color hex string, e.g. #00CCFF

Schema that defines a valid color hex string, e.g. #00CCFF

  • Coerces the value to a six-digit uppercase #RRGGBB hex string.
  • Rejects anything that isn't a valid hex color (use NULLABLE_COLOR to also allow null).

Examples

COLOR.validate("00ccff"); // Returns "#00CCFF"