Allow icons to be optional
This commit is contained in:
parent
c745e18b5d
commit
3b05c1543a
|
@ -1,5 +1,6 @@
|
||||||
import { icons } from "@iconify-json/material-symbols";
|
import { icons } from "@iconify-json/material-symbols";
|
||||||
import { TextField } from "payload/types";
|
import { TextField } from "payload/types";
|
||||||
|
import { isEmpty } from "../../utils/asserts";
|
||||||
|
|
||||||
type Props = Omit<TextField, "type" | "hasMany" | "maxRows" | "minRows">;
|
type Props = Omit<TextField, "type" | "hasMany" | "maxRows" | "minRows">;
|
||||||
|
|
||||||
|
@ -12,7 +13,8 @@ export const iconField = (props: Props): TextField => ({
|
||||||
description:
|
description:
|
||||||
"Select an icon from here: https://icones.js.org/collection/material-symbols. Only outline and regular variants are usable on the website.",
|
"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)) {
|
if (!validNames.includes(value)) {
|
||||||
return `The icon "${value}" doesn't exist in material-symbols`;
|
return `The icon "${value}" doesn't exist in material-symbols`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue