Skip to content

Commit e37f449

Browse files
author
andy.patterson
committed
docs: generate documentation
1 parent bfb2528 commit e37f449

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ if (validator.isValid(data)) doThing(data); // typeof data => `string`
219219
else throw new Error('oops!'); // typeof data => `any`
220220
```
221221

222+
### TypeToSchemaOptions
223+
222224
### union
223225
Creates a `Validator` instance that matches on any one of the given list of possible types.
224226

@@ -344,6 +346,22 @@ if (result.valid) doThing(result.data);
344346
else logger.error(...result.errors);
345347
```
346348

349+
### Validator.withOptions
350+
Add additional validations to the generated schema.
351+
While most of these validations are not representable at compile time
352+
with typescript (`minLength` of a `string` for instance), it can be helpful
353+
to have the additional validations when validating runtime types.
354+
355+
| Param | Description |
356+
| --- | --- |
357+
| opts | JSON schema specific options (for instance: `{ maxLength: 2, minLength: 0 }`) |
358+
###### Example:
359+
```typescript
360+
const validator = v.string().withOptions({ minLength: 1 });
361+
validator.isValid(''); // false
362+
validator.isValid('hi'); // true
363+
```
364+
347365
### ValidType
348366
Returns the encapsulated type of a `Validator` type.
349367
###### Example:

0 commit comments

Comments
 (0)