UNPKG

@tsed/schema

Version:
24 lines (23 loc) 580 B
import { DecoratorTypes } from "@tsed/core"; import { JsonEntityFn } from "./jsonEntityFn.js"; /** * Add optional annotation on Property or Parameter. * * @decorator * @validation * @swagger * @schema * @input */ export function Optional() { return JsonEntityFn((store) => { switch (store.decoratorType) { case DecoratorTypes.PARAM: store.required = false; break; case DecoratorTypes.PROP: store.parentSchema.removeRequired(store.propertyName); break; } }); }