Skip to content

Commit 71d1c16

Browse files
author
andy.patterson
committedJul 19, 2018
docs: generate documentation
1 parent 781725f commit 71d1c16

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎README.md

+16
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,22 @@ if (result.valid) doThing(result.data);
344344
else logger.error(...result.errors);
345345
```
346346

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+
347363
### ValidType
348364
Returns the encapsulated type of a `Validator` type.
349365
###### Example:

0 commit comments

Comments
 (0)
Please sign in to comment.