rgb / rgba doesn't validate

Created on 22 April 2024, 7 months ago
Updated 24 April 2024, 7 months ago

The regular expression in the validateFormElement doesn't seem to validate for correct rgb / rgba values.
I've reviewed the regular expression for HEX, rbg, rgba, hsl and hsla values and this one seems to work:

preg_match("/(?(DEFINE)(?<rgb>[0-9]|[1-9][0-9]|[1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))(?(DEFINE)(?<del>\,{1}\s?))(?(DEFINE)(?<hue>[0-9]|[1-9][0-9]|[1-2][0-9][0-9]|[3][0-5][0-9]|[3][6][0]))(?(DEFINE)(?<percent>[0-9]|[1-9][0-9]|[1][0][0]))(?(DEFINE)(?<alpha>0?\.[0-9]{1,2}))^\#((((\d|[a-f]){3}){1,2})|((\d|[a-f]){8}))$|^rgba\(\g'rgb'\g'del'\g'rgb'\g'del'\g'rgb'\g'del'\g'alpha'\)$|^rgb\(\g'rgb'\g'del'\g'rgb'\g'del'\g'rgb'\)$|^hsl\(\g'hue'\g'del'\g'percent'\%\g'del'\g'percent'\%\)$|^hsla\(\g'hue'\g'del'\g'percent'\%\g'del'\g'percent'\%\g'del'\g'alpha'\)$/", $value, $matches);
🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇧🇪Belgium kensae

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024