From 734f4a150c5aa29eaa1b200c731fb4c8903d9935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Qu=E1=BB=91c=20=C4=90=E1=BA=A1t?= Date: Fri, 19 Jan 2024 18:09:22 +0700 Subject: [PATCH] chore: use `hex_color` rule for color validation (#3936) --- extensions/tags/src/TagValidator.php | 2 +- framework/core/locale/validation.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/tags/src/TagValidator.php b/extensions/tags/src/TagValidator.php index d4cdbb435..cf1d9c528 100644 --- a/extensions/tags/src/TagValidator.php +++ b/extensions/tags/src/TagValidator.php @@ -18,6 +18,6 @@ class TagValidator extends AbstractValidator 'slug' => ['required', 'unique:tags', 'regex:/^[^\/\\ ]*$/i'], 'is_hidden' => ['bool'], 'description' => ['string', 'max:700'], - 'color' => ['regex:/^#([a-f0-9]{6}|[a-f0-9]{3})$/i'], + 'color' => ['hex_color'], ]; } diff --git a/framework/core/locale/validation.yml b/framework/core/locale/validation.yml index 934d1739d..7c2b40189 100644 --- a/framework/core/locale/validation.yml +++ b/framework/core/locale/validation.yml @@ -41,6 +41,7 @@ validation: file: "The :attribute must be greater than or equal :value kilobytes." string: "The :attribute must be greater than or equal :value characters." array: "The :attribute must have :value items or more." + hex_color: "The :attribute field must be a valid hexadecimal color." image: "The :attribute must be an image." in: "The selected :attribute is invalid." in_array: "The :attribute field does not exist in :other."