Skip to content

Added the ability to use a reference for Array min/max/length#1206

Merged
DavidTPate merged 1 commit intohapijs:masterfrom
DavidTPate:array-length-ref
Jun 12, 2017
Merged

Added the ability to use a reference for Array min/max/length#1206
DavidTPate merged 1 commit intohapijs:masterfrom
DavidTPate:array-length-ref

Conversation

@DavidTPate
Copy link
Contributor

@DavidTPate DavidTPate commented Jun 1, 2017

This PR adds the ability for a user to use a reference for array().length(), array().min() and array().max() as well as adding test cases and documentation around the functionality.

Fixes #1017

@DavidTPate DavidTPate added the feature New functionality or improvement label Jun 1, 2017
@DavidTPate DavidTPate changed the title Added the ability to use a reference for array().length() Added the ability to use a reference for Array min/max/length Jun 1, 2017
@DavidTPate DavidTPate self-assigned this Jun 1, 2017
Copy link
Contributor

@WesTyler WesTyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it

```js
const schema = Joi.object({
length: Joi.number().integer().required(),
numbers: Joi.array().length(Joi.ref('limit')).required()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy pasta got you ;)
Joi.ref('limit') vs Joi.ref('length')

arr: [1, 2]
}, false, null, 'child "arr" fails because ["arr" references "limit" which is not a number]'],
[{
limit: 'I like turtles',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;)

`array().min(), and `array().max()`.

Fixes #1017
@DavidTPate DavidTPate merged commit 3188776 into hapijs:master Jun 12, 2017
@DavidTPate DavidTPate deleted the array-length-ref branch June 12, 2017 21:18
@Marsup Marsup added this to the 10.6.0 milestone Jun 12, 2017
Marsup added a commit that referenced this pull request Jun 12, 2017
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array length cannot reference to another field

3 participants