This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/modelSchema/common/hexColor.ts

11 lines
265 B
TypeScript

import { string } from 'zod'
import isHexColor from 'validator/lib/isHexColor'
export const HexColorSchema = string().transform(
(value) => {
if (!value || value.startsWith('#')) {
return value
}
return '#' + value
}).refine(value => isHexColor(value))