OPTIONAL()function
OPTIONAL(source: Schema<T>): OptionalSchema<T>
| Param | Type | |
|---|---|---|
source | Schema<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
const schema = OPTIONAL(STRING); schema.validate(undefined); // Returns undefined