default()
Sets a default value.
default(value: T | (() => T)): this;
Notes
- The default value is used if the input value is undefined.
- Can be a static value or a callback function that returns a value.
- Does not require calling optional() first; undefined values are replaced by the default.
Parameters
- value — The default value, or a callback that returns the default value.
Return value
This builder, for chaining.
Examples
f.string().default("abc");
f.number().default(() => Math.random());
Related
class Builder static
A class that represents a validation builder for an input value.
