File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -344,6 +344,22 @@ if (result.valid) doThing(result.data);
344
344
else logger .error (... result .errors );
345
345
```
346
346
347
+ ### Validator.withOptions
348
+ Add additional validations to the generated schema.
349
+ While most of these validations are not representable at compile time
350
+ with typescript (` minLength ` of a ` string ` for instance), it can be helpful
351
+ to have the additional validations when validating runtime types.
352
+
353
+ | Param | Description |
354
+ | --- | --- |
355
+ | opts | JSON schema specific options (for instance: ` { maxLength: 2, minLength: 0 } ` ) |
356
+ ###### Example:
357
+ ``` typescript
358
+ const validator = v .string ().withOptions ({ minLength: 1 });
359
+ validator .isValid (' ' ); // false
360
+ validator .isValid (' hi' ); // true
361
+ ```
362
+
347
363
### ValidType
348
364
Returns the encapsulated type of a ` Validator ` type.
349
365
###### Example:
You can’t perform that action at this time.
0 commit comments