Skip to content

Commit

Permalink
object.assert() fixes. Closes #2026. Closes #2027
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Aug 8, 2019
1 parent b8084c7 commit be3c863
Show file tree
Hide file tree
Showing 7 changed files with 1,694 additions and 1,842 deletions.
12 changes: 6 additions & 6 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
- [`object` - inherits from `Any`](#object---inherits-from-any)
- [`object.and(...peers, [options])`](#objectandpeers-options)
- [`object.append([schema])`](#objectappendschema)
- [`object.assert(ref, schema, [message])`](#objectassertref-schema-message)
- [`object.assert(subject, schema, [message])`](#objectassertsubject-schema-message)
- [`object.instance(constructor, [name])`](#objectinstanceconstructor-name)
- [`object.keys([schema])`](#objectkeysschema)
- [`object.length(limit)`](#objectlengthlimit)
Expand Down Expand Up @@ -2293,12 +2293,12 @@ const extended = base.append({
});
```

#### `object.assert(ref, schema, [message])`
#### `object.assert(subject, schema, [message])`

Verifies an assertion where:
- `ref` - the key name or [reference](#refkey-options).
- `subject` - the key name, [reference](#refkey-options), or template expression to validate.
- `schema` - the validation rules required to satisfy the assertion. If the `schema` includes references, they are resolved against
the object value, not the value of the `ref` target.
the object value, not the value of the `subject` target.
- `message` - optional human-readable message used when the assertion fails. Defaults to 'failed to pass the assertion test'.

```js
Expand Down Expand Up @@ -3804,8 +3804,8 @@ The schema on an [`object.assert()`](#objectassertref-schema-message) failed to
Additional local context properties:
```ts
{
ref: string, // Dotted path to the property that was checked
message: string // Custom message or default one
subject: object, // The assertion subject. When it is a reference, use subject.key for the display path.
message: string // Custom message when provided
}
```

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ that stores information) to ensure *validation* of key information.

## API

See the detailed [API Reference](https://github.com/hapijs/joi/blob/v16.0.0-rc2/API.md).
See the detailed [API Reference](https://github.com/hapijs/joi/blob/v16.0.0/API.md).

## Example

Expand Down
Loading

0 comments on commit be3c863

Please sign in to comment.