import { HasTag, SomeSpec, Spec, SpecKind, SpecSuccess, SpecTag, SpectypesError } from './types.js' import { error } from './error.js' /** * Creates an optional object property validator spec. Can be used only inside 'object' and 'struct' * arguments. Will not produce any validation errors if property equals undefined or is not present * in the validated object. * * @param spec Non-optional spec */ export const optional: ( spec: HasTag extends true ? SpectypesError<'optional', 'optional'> : HasTag extends true ? SpectypesError<'filter', 'optional'> : HasTag extends true ? SpectypesError<'lazy', 'optional'> : ItemSpec ) => Spec< ['optional', ...SpecTag], SpecKind, SpecSuccess | undefined > = error