Closed balwaan1986 closed 8 years ago
And the proper test would then be
it('should validate arrays', function () {
expect(valdrUtil.notEmpty(['Apple', 'Banana'])).toBe(true);
expect(valdrUtil.isEmpty(['Apple', 'Banana'])).toBe(false);
expect(valdrUtil.isEmpty([])).toBe(true);
expect(valdrUtil.notEmpty([])).toBe(false);
});
Agree?
Yup.. this is perfect.. Thank you!
I'm using ui-select for dropdowns and valdr required field validation works like a charm for single select. However, it does not work for multiselect dropdowns.
I figured out the problem was due to valdrUtil.notEmpty method. Here it is checking if the value is undefined, empty string or null value. For a multiselect dropdown, it will be an empty array.
So we can fix this by adding a check to see if the value is an array and if yes, check its length property. If its 0, it means its an empty array and hence should return false.
Is this something that can be included in the next release?