Skip to content

Commit

Permalink
feat(Schema): support nested object check with checkForField and `c…
Browse files Browse the repository at this point in the history
…heckForFieldAsync` (#76)

* feat(Schema): support nested object check with checkForField and checkForFieldAsync
* docs: update README.md
* test: add tests for ObjectType
  • Loading branch information
simonguo authored Apr 9, 2024
1 parent 349dc42 commit e315aec
Show file tree
Hide file tree
Showing 14 changed files with 581 additions and 589 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Schema for data modeling & validation
- [`static combine(...models)`](#static-combinemodels)
- [`check(data: object)`](#checkdata-object)
- [`checkAsync(data: object)`](#checkasyncdata-object)
- [`checkForField(fieldName: string, data: object)`](#checkforfieldfieldname-string-data-object)
- [`checkForFieldAsync(fieldName: string, data: object)`](#checkforfieldasyncfieldname-string-data-object)
- [`checkForField(fieldName: string, data: object, options?: { nestedObject?: boolean })`](#checkforfieldfieldname-string-data-object-options--nestedobject-boolean-)
- [`checkForFieldAsync(fieldName: string, data: object, options?: { nestedObject?: boolean })`](#checkforfieldasyncfieldname-string-data-object-options--nestedobject-boolean-)
- [MixedType()](#mixedtype)
- [`isRequired(errorMessage?: string, trim: boolean = true)`](#isrequirederrormessage-string-trim-boolean--true)
- [`isRequiredOrEmpty(errorMessage?: string, trim: boolean = true)`](#isrequiredoremptyerrormessage-string-trim-boolean--true)
Expand Down Expand Up @@ -367,7 +367,7 @@ model
});
```

#### `checkForField(fieldName: string, data: object)`
#### `checkForField(fieldName: string, data: object, options?: { nestedObject?: boolean })`

Check whether a field in the data conforms to the model shape definition. Return a check result.

Expand All @@ -384,7 +384,7 @@ const data = {
model.checkForField('username', data);
```

#### `checkForFieldAsync(fieldName: string, data: object)`
#### `checkForFieldAsync(fieldName: string, data: object, options?: { nestedObject?: boolean })`

Asynchronously check whether a field in the data conforms to the model shape definition. Return a check result.

Expand Down
Loading

0 comments on commit e315aec

Please sign in to comment.