Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/asserts/callback-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { Violation } = require('validator.js');
* Constants.
*/

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

/**
* Export `CallbackAssert`.
Expand Down
8 changes: 8 additions & 0 deletions test/asserts/callback-assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ describe('CallbackAssert', () => {
}
});

it('should expose `assert` equal to `Custom_Class1`', () => {
try {
Assert.callback(value => value === 'foobiz', 'Custom_Class1').validate('foobar');
} catch (e) {
expect(e.show().assert).toEqual('Custom_Class1');
}
});

it('should not throw an error if the callback function returns `true`', () => {
Assert.callback(value => value === 'foobar', 'CustomClass').validate('foobar');
});
Expand Down