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.
|
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)) |