Skip to content

Commit 53230c0

Browse files
committed
Add support for underscores to be in callback assert custom class
1 parent a7518c6 commit 53230c0

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/asserts/callback-assert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { Violation } = require('validator.js');
1111
* Constants.
1212
*/
1313

14-
const expression = /^[a-zA-Z\d]+$/;
14+
const expression = /^[a-zA-Z\d_]+$/;
1515

1616
/**
1717
* Export `CallbackAssert`.

test/asserts/callback-assert.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ describe('CallbackAssert', () => {
9191
}
9292
});
9393

94+
it('should expose `assert` equal to `Custom_Class1`', () => {
95+
try {
96+
Assert.callback(value => value === 'foobiz', 'Custom_Class1').validate('foobar');
97+
} catch (e) {
98+
expect(e.show().assert).toEqual('Custom_Class1');
99+
}
100+
});
101+
94102
it('should not throw an error if the callback function returns `true`', () => {
95103
Assert.callback(value => value === 'foobar', 'CustomClass').validate('foobar');
96104
});

0 commit comments

Comments
 (0)