From 3b05c1543a54db2a0640931d3ef6b36bc44479ea Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sun, 12 May 2024 23:18:28 +0200 Subject: [PATCH] Allow icons to be optional --- src/fields/iconField/iconField.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fields/iconField/iconField.ts b/src/fields/iconField/iconField.ts index 3a25d49..bbbd1b8 100644 --- a/src/fields/iconField/iconField.ts +++ b/src/fields/iconField/iconField.ts @@ -1,5 +1,6 @@ import { icons } from "@iconify-json/material-symbols"; import { TextField } from "payload/types"; +import { isEmpty } from "../../utils/asserts"; type Props = Omit; @@ -12,7 +13,8 @@ export const iconField = (props: Props): TextField => ({ description: "Select an icon from here: https://icones.js.org/collection/material-symbols. Only outline and regular variants are usable on the website.", }, - validate: (value) => { + validate: async (value) => { + if (isEmpty(value)) return true; if (!validNames.includes(value)) { return `The icon "${value}" doesn't exist in material-symbols`; }