Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions test/validators/isLength.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,31 @@ describe('isLength', () => {
valid: ['👩🦰👩👩👦👦🏳️🌈', '⏩︎⏩︎⏪︎⏪︎⏭︎⏭︎⏮︎⏮︎'],
});
});

it('should return true if string exactly match min/max bounds', () => {
test({
validator: 'isLength',
args: [{ min: 3, max: 3 }],
valid: ['abc', 'def'],
invalid: ['abcd', 'efgh'],
});
});

it('should count emojis as single character', () => {
test({
validator: 'isLength',
args: [{ min: 1, max: 1 }],
valid: ['🚀', '🍕', 'A'],
invalid: ['🚀🚀', ''],
});
});

it('should only allow strings with specific lengths from a list', () => {
test({
validator: 'isLength',
args: [{ discreteLengths: [2, 5] }],
valid: ['to', 'hello'],
invalid: ['a', 'cat', 'lengthy'],
});
});
});
Loading