co.validation 1.0.0-RC.4 → 1.0.0-RC.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -563,8 +563,8 @@ describe('createValidation', () => {
563
563
  expect((0, _.createValidation)({
564
564
  type: 'all',
565
565
  validators: [{
566
- type: 'number',
567
- getMessage: () => 'Number'
566
+ type: 'email',
567
+ getMessage: () => 'Email'
568
568
  }, {
569
569
  type: 'maxLength',
570
570
  max: 1,
@@ -572,7 +572,7 @@ describe('createValidation', () => {
572
572
  }]
573
573
  })('xz')).toEqual({
574
574
  data: undefined,
575
- errors: ['Number', 'MaxLength']
575
+ errors: ['Email', 'MaxLength']
576
576
  });
577
577
  expect((0, _.createValidation)({
578
578
  type: 'all',
@@ -580,19 +580,19 @@ describe('createValidation', () => {
580
580
  type: 'number',
581
581
  getMessage: () => 'Number'
582
582
  }, {
583
- type: 'maxLength',
584
- max: 1,
585
- getMessage: () => 'MaxLength'
583
+ type: 'maxValue',
584
+ max: 11,
585
+ getMessage: () => 'MaxValue'
586
586
  }]
587
587
  })('12')).toEqual({
588
588
  data: undefined,
589
- errors: ['MaxLength']
589
+ errors: ['MaxValue']
590
590
  });
591
591
  expect((0, _.createValidation)({
592
592
  type: 'all',
593
593
  validators: [{
594
- type: 'number',
595
- getMessage: () => 'Number'
594
+ type: 'email',
595
+ getMessage: () => 'Email'
596
596
  }, {
597
597
  type: 'maxLength',
598
598
  max: 1,
@@ -600,7 +600,7 @@ describe('createValidation', () => {
600
600
  }]
601
601
  })('x')).toEqual({
602
602
  data: undefined,
603
- errors: ['Number']
603
+ errors: ['Email']
604
604
  });
605
605
  expect((0, _.createValidation)({
606
606
  type: 'all',
@@ -608,12 +608,12 @@ describe('createValidation', () => {
608
608
  type: 'number',
609
609
  getMessage: () => 'Number'
610
610
  }, {
611
- type: 'maxLength',
611
+ type: 'maxValue',
612
612
  max: 1,
613
- getMessage: () => 'MaxLength'
613
+ getMessage: () => 'MaxValue'
614
614
  }]
615
615
  })('1')).toEqual({
616
- data: '1',
616
+ data: 1,
617
617
  errors: undefined
618
618
  });
619
619
  });
@@ -37,6 +37,14 @@ const registrationFormValidation = (0, _.createValidation)({
37
37
  type: 'email'
38
38
  }]
39
39
  },
40
+ age: {
41
+ type: 'all',
42
+ validators: [{
43
+ type: 'required'
44
+ }, {
45
+ type: 'number'
46
+ }]
47
+ },
40
48
  hobbies: {
41
49
  type: 'array',
42
50
  itemRule: {
@@ -82,7 +90,8 @@ describe('registrationFormValidation', () => {
82
90
  expect(validationResult.errors).toEqual({
83
91
  firstName: ['Required'],
84
92
  lastName: ['Required'],
85
- email: ['Required']
93
+ email: ['Required'],
94
+ age: ['Required']
86
95
  });
87
96
  expect(validationResult.data).toEqual(undefined);
88
97
  });
@@ -94,7 +103,8 @@ describe('registrationFormValidation', () => {
94
103
  expect(validationResult.errors).toEqual({
95
104
  firstName: ['Required'],
96
105
  lastName: ['Required'],
97
- email: ['Required']
106
+ email: ['Required'],
107
+ age: ['Required']
98
108
  });
99
109
  expect(validationResult.data).toEqual(validatedObject);
100
110
  });
@@ -125,6 +135,7 @@ describe('registrationFormValidation', () => {
125
135
  firstName: 'firstName',
126
136
  lastName: 'lastName',
127
137
  email: 'test@mail.com',
138
+ age: '12',
128
139
  hobbies: [1, {
129
140
  title: 'title'
130
141
  }, {
@@ -166,6 +177,7 @@ describe('registrationFormValidation', () => {
166
177
  firstName: 'firstName',
167
178
  lastName: 'lastName',
168
179
  email: 'test@mail.com',
180
+ age: 12,
169
181
  hobbies: [{
170
182
  title: 'title'
171
183
  }, {
package/lib/operators.js CHANGED
@@ -57,6 +57,8 @@ const all = (...validators) => {
57
57
  } else {
58
58
  validationErrors.push(currentResult.errors);
59
59
  }
60
+ } else {
61
+ value = currentResult.data;
60
62
  }
61
63
 
62
64
  return validationErrors;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co.validation",
3
- "version": "1.0.0-RC.4",
3
+ "version": "1.0.0-RC.5",
4
4
  "description": "JSON based fluent validation for browser, node.js, redux-form and anything javascript compatible.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {