OPTIONAL()function

OPTIONAL(source: Schema<T>): OptionalSchema<T>
ParamType
sourceSchema<T>
Source schema to wrap. required
Return
OptionalSchema<T>
Schema that wraps a source schema and additionally allows undefined.

Create an OptionalSchema that wraps a source schema and also allows undefined.

Sugar factory for OptionalSchema.

Examples

OPTIONAL(STRING).validate(undefined); // Returns undefined