Closed samliebow closed 5 years ago
I underdiagnosed the problem in https://github.com/hapijs/hoek/issues/323: a reference doesn't have to be empty for the only flag to allow values that aren't in the ref. The underlying issue appears to be the same: there's nothing in the ref that isn't in the values, so there's no misses, so this block returns true: https://github.com/hapijs/hoek/blob/dca090d1da8515b48c235afbba0ca187f4b3c476/lib/contain.js#L139-L143
only
values
ref
misses
Examples:
contain(['a', 'b'], ['a', 'b', 'c']) // false contain(['a', 'b'], ['a', 'b', 'c'], { only: true }) // true contain(['a', 'b'], ['a', 'b', 'c'], { only: true, once: true }) // false contain('ab', ['a', 'b', 'c']) // false contain('ab', ['a', 'b', 'c'], { only: true }) // true contain('ab', ['a', 'b', 'c'], { only: true, once: true }) // false contain({ a: 'foo', b: 'bar' }, ['a', 'b', 'c']) // false contain({ a: 'foo', b: 'bar' }, ['a', 'b', 'c'], { only: true }) // true contain({ a: 'foo', b: 'bar' }, ['a', 'b', 'c'], { only: true, once: true }) // false
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.
I underdiagnosed the problem in https://github.com/hapijs/hoek/issues/323: a reference doesn't have to be empty for the
only
flag to allowvalues
that aren't in theref
. The underlying issue appears to be the same: there's nothing in theref
that isn't in thevalues
, so there's nomisses
, so this block returns true: https://github.com/hapijs/hoek/blob/dca090d1da8515b48c235afbba0ca187f4b3c476/lib/contain.js#L139-L143Examples: