@@ -189,6 +189,41 @@ describe('New validators', () => {
189
189
it ( 'should return numberValidator and fail' , ( ) => {
190
190
expect ( dataTypeValidator ( 'integer' ) ( { message : 'Should be super interger' } ) ( 'Foo' ) ) . toEqual ( 'Should be super interger' ) ;
191
191
} ) ;
192
+
193
+ describe ( 'data-type arrays' , ( ) => {
194
+ it ( 'should pass validation of an array of strings' , ( ) => {
195
+ expect ( dataTypeValidator ( 'string' ) ( ) ( [ 'Foo' , 'Bar' , 'Baz' ] ) ) . toBeUndefined ( ) ;
196
+ } ) ;
197
+
198
+ it ( 'should fail validation of an array of strings' , ( ) => {
199
+ expect ( dataTypeValidator ( 'string' ) ( ) ( [ 'Foo' , 'Bar' , 2 ] ) ) . toBe ( 'Field value has to be string' ) ;
200
+ } ) ;
201
+
202
+ it ( 'should pass validation of an array of integers' , ( ) => {
203
+ expect ( dataTypeValidator ( 'integer' ) ( ) ( [ 1 , 2 , 3 ] ) ) . toBeUndefined ( ) ;
204
+ } ) ;
205
+
206
+ it ( 'should fail validation of an array of strings' , ( ) => {
207
+ expect ( dataTypeValidator ( 'integer' ) ( ) ( [ 1 , 2 , 2.1 ] ) ) . toBe ( 'Value must be integer' ) ;
208
+ expect ( dataTypeValidator ( 'integer' ) ( ) ( [ 1 , 2 , 'foo' ] ) ) . toBe ( 'Value must be integer' ) ;
209
+ } ) ;
210
+
211
+ it ( 'should pass validation of an array of numbers' , ( ) => {
212
+ expect ( dataTypeValidator ( 'number' ) ( ) ( [ 1 , 2 , 3.1 ] ) ) . toBeUndefined ( ) ;
213
+ } ) ;
214
+
215
+ it ( 'should fail validation of an array of numbers' , ( ) => {
216
+ expect ( dataTypeValidator ( 'number' ) ( ) ( [ 1 , 2 , 'foo' ] ) ) . toBe ( 'Values must be number' ) ;
217
+ } ) ;
218
+
219
+ it ( 'should pass validation of an array of booleans' , ( ) => {
220
+ expect ( dataTypeValidator ( 'boolean' ) ( ) ( [ true , true , false , false ] ) ) . toBeUndefined ( ) ;
221
+ } ) ;
222
+
223
+ it ( 'should fail validation of an array of booleans' , ( ) => {
224
+ expect ( dataTypeValidator ( 'boolean' ) ( ) ( [ 'foo' , 2 , true ] ) ) . toBe ( 'Field value has to be boolean' ) ;
225
+ } ) ;
226
+ } ) ;
192
227
} ) ;
193
228
describe ( 'Validators default messages overrides' , ( ) => {
194
229
beforeAll ( ( ) => {
0 commit comments