ruby-livr 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +45 -0
  7. data/Readme.md +119 -0
  8. data/lib/livr.rb +60 -0
  9. data/lib/livr/aliased_rule.rb +26 -0
  10. data/lib/livr/rule.rb +21 -0
  11. data/lib/livr/rules/common.rb +35 -0
  12. data/lib/livr/rules/meta.rb +200 -0
  13. data/lib/livr/rules/modifiers.rb +68 -0
  14. data/lib/livr/rules/numeric.rb +136 -0
  15. data/lib/livr/rules/special.rb +65 -0
  16. data/lib/livr/rules/string.rb +150 -0
  17. data/lib/livr/validator.rb +134 -0
  18. data/ruby-livr.gemspec +19 -0
  19. data/spec/01-test_suite_spec.rb +34 -0
  20. data/spec/02-aliases_spec.rb +21 -0
  21. data/spec/03-auto_trim_spec.rb +56 -0
  22. data/spec/04-custom_filters_spec.rb +54 -0
  23. data/spec/05-rules_replacement_spec.rb +67 -0
  24. data/spec/spec_helper.rb +3 -0
  25. data/spec/test_suite/aliases_negative/01-adult_age/aliases.json +12 -0
  26. data/spec/test_suite/aliases_negative/01-adult_age/errors.json +6 -0
  27. data/spec/test_suite/aliases_negative/01-adult_age/input.json +11 -0
  28. data/spec/test_suite/aliases_negative/01-adult_age/rules.json +10 -0
  29. data/spec/test_suite/aliases_negative/02-address/aliases.json +20 -0
  30. data/spec/test_suite/aliases_negative/02-address/errors.json +8 -0
  31. data/spec/test_suite/aliases_negative/02-address/input.json +13 -0
  32. data/spec/test_suite/aliases_negative/02-address/rules.json +4 -0
  33. data/spec/test_suite/aliases_negative/03-adult_age_in_user/aliases.json +31 -0
  34. data/spec/test_suite/aliases_negative/03-adult_age_in_user/errors.json +8 -0
  35. data/spec/test_suite/aliases_negative/03-adult_age_in_user/input.json +14 -0
  36. data/spec/test_suite/aliases_negative/03-adult_age_in_user/rules.json +4 -0
  37. data/spec/test_suite/aliases_positive/01-adult_age/aliases.json +12 -0
  38. data/spec/test_suite/aliases_positive/01-adult_age/input.json +11 -0
  39. data/spec/test_suite/aliases_positive/01-adult_age/output.json +10 -0
  40. data/spec/test_suite/aliases_positive/01-adult_age/rules.json +10 -0
  41. data/spec/test_suite/aliases_positive/02-address/aliases.json +20 -0
  42. data/spec/test_suite/aliases_positive/02-address/input.json +13 -0
  43. data/spec/test_suite/aliases_positive/02-address/output.json +12 -0
  44. data/spec/test_suite/aliases_positive/02-address/rules.json +4 -0
  45. data/spec/test_suite/aliases_positive/03-adult_age_in_user/aliases.json +31 -0
  46. data/spec/test_suite/aliases_positive/03-adult_age_in_user/input.json +14 -0
  47. data/spec/test_suite/aliases_positive/03-adult_age_in_user/output.json +12 -0
  48. data/spec/test_suite/aliases_positive/03-adult_age_in_user/rules.json +4 -0
  49. data/spec/test_suite/negative/01-required/errors.json +5 -0
  50. data/spec/test_suite/negative/01-required/input.json +10 -0
  51. data/spec/test_suite/negative/01-required/rules.json +10 -0
  52. data/spec/test_suite/negative/02-not_empty/errors.json +3 -0
  53. data/spec/test_suite/negative/02-not_empty/input.json +10 -0
  54. data/spec/test_suite/negative/02-not_empty/rules.json +10 -0
  55. data/spec/test_suite/negative/03-one_of/errors.json +11 -0
  56. data/spec/test_suite/negative/03-one_of/input.json +12 -0
  57. data/spec/test_suite/negative/03-one_of/rules.json +11 -0
  58. data/spec/test_suite/negative/04-min_length/errors.json +10 -0
  59. data/spec/test_suite/negative/04-min_length/input.json +12 -0
  60. data/spec/test_suite/negative/04-min_length/rules.json +11 -0
  61. data/spec/test_suite/negative/05-max_length/errors.json +10 -0
  62. data/spec/test_suite/negative/05-max_length/input.json +12 -0
  63. data/spec/test_suite/negative/05-max_length/rules.json +11 -0
  64. data/spec/test_suite/negative/06-length_equal/errors.json +10 -0
  65. data/spec/test_suite/negative/06-length_equal/input.json +12 -0
  66. data/spec/test_suite/negative/06-length_equal/rules.json +11 -0
  67. data/spec/test_suite/negative/07-length_between/errors.json +10 -0
  68. data/spec/test_suite/negative/07-length_between/input.json +12 -0
  69. data/spec/test_suite/negative/07-length_between/rules.json +11 -0
  70. data/spec/test_suite/negative/08-like/errors.json +11 -0
  71. data/spec/test_suite/negative/08-like/input.json +14 -0
  72. data/spec/test_suite/negative/08-like/rules.json +12 -0
  73. data/spec/test_suite/negative/09-integer/errors.json +11 -0
  74. data/spec/test_suite/negative/09-integer/input.json +13 -0
  75. data/spec/test_suite/negative/09-integer/rules.json +12 -0
  76. data/spec/test_suite/negative/10-positive_integer/errors.json +11 -0
  77. data/spec/test_suite/negative/10-positive_integer/input.json +13 -0
  78. data/spec/test_suite/negative/10-positive_integer/rules.json +12 -0
  79. data/spec/test_suite/negative/11-decimal/errors.json +11 -0
  80. data/spec/test_suite/negative/11-decimal/input.json +13 -0
  81. data/spec/test_suite/negative/11-decimal/rules.json +12 -0
  82. data/spec/test_suite/negative/12-positive_decimal/errors.json +11 -0
  83. data/spec/test_suite/negative/12-positive_decimal/input.json +13 -0
  84. data/spec/test_suite/negative/12-positive_decimal/rules.json +12 -0
  85. data/spec/test_suite/negative/13-max_number/errors.json +10 -0
  86. data/spec/test_suite/negative/13-max_number/input.json +12 -0
  87. data/spec/test_suite/negative/13-max_number/rules.json +11 -0
  88. data/spec/test_suite/negative/14-min_number/errors.json +11 -0
  89. data/spec/test_suite/negative/14-min_number/input.json +13 -0
  90. data/spec/test_suite/negative/14-min_number/rules.json +12 -0
  91. data/spec/test_suite/negative/15-number_beetween/errors.json +12 -0
  92. data/spec/test_suite/negative/15-number_beetween/input.json +14 -0
  93. data/spec/test_suite/negative/15-number_beetween/rules.json +13 -0
  94. data/spec/test_suite/negative/16-email/errors.json +12 -0
  95. data/spec/test_suite/negative/16-email/input.json +14 -0
  96. data/spec/test_suite/negative/16-email/rules.json +13 -0
  97. data/spec/test_suite/negative/17-equal_to_field/errors.json +10 -0
  98. data/spec/test_suite/negative/17-equal_to_field/input.json +12 -0
  99. data/spec/test_suite/negative/17-equal_to_field/rules.json +11 -0
  100. data/spec/test_suite/negative/18-nested_object/errors.json +9 -0
  101. data/spec/test_suite/negative/18-nested_object/input.json +9 -0
  102. data/spec/test_suite/negative/18-nested_object/rules.json +9 -0
  103. data/spec/test_suite/negative/19-list_of/errors.json +6 -0
  104. data/spec/test_suite/negative/19-list_of/input.json +6 -0
  105. data/spec/test_suite/negative/19-list_of/rules.json +14 -0
  106. data/spec/test_suite/negative/20-list_of_objects/errors.json +14 -0
  107. data/spec/test_suite/negative/20-list_of_objects/input.json +18 -0
  108. data/spec/test_suite/negative/20-list_of_objects/rules.json +7 -0
  109. data/spec/test_suite/negative/21-list_of_different_objects/errors.json +17 -0
  110. data/spec/test_suite/negative/21-list_of_different_objects/input.json +26 -0
  111. data/spec/test_suite/negative/21-list_of_different_objects/rules.json +17 -0
  112. data/spec/test_suite/negative/22-not_empty_list/errors.json +7 -0
  113. data/spec/test_suite/negative/22-not_empty_list/input.json +6 -0
  114. data/spec/test_suite/negative/22-not_empty_list/rules.json +7 -0
  115. data/spec/test_suite/negative/23-url/errors.json +10 -0
  116. data/spec/test_suite/negative/23-url/input.json +12 -0
  117. data/spec/test_suite/negative/23-url/rules.json +11 -0
  118. data/spec/test_suite/negative/24-iso_date/errors.json +11 -0
  119. data/spec/test_suite/negative/24-iso_date/input.json +13 -0
  120. data/spec/test_suite/negative/24-iso_date/rules.json +12 -0
  121. data/spec/test_suite/negative/25-eq/errors.json +13 -0
  122. data/spec/test_suite/negative/25-eq/input.json +14 -0
  123. data/spec/test_suite/negative/25-eq/rules.json +13 -0
  124. data/spec/test_suite/negative/26-string/errors.json +6 -0
  125. data/spec/test_suite/negative/26-string/input.json +6 -0
  126. data/spec/test_suite/negative/26-string/rules.json +6 -0
  127. data/spec/test_suite/negative/27-any_object/errors.json +6 -0
  128. data/spec/test_suite/negative/27-any_object/input.json +6 -0
  129. data/spec/test_suite/negative/27-any_object/rules.json +6 -0
  130. data/spec/test_suite/negative/28-variable_object/errors.json +15 -0
  131. data/spec/test_suite/negative/28-variable_object/input.json +24 -0
  132. data/spec/test_suite/negative/28-variable_object/rules.json +77 -0
  133. data/spec/test_suite/negative/29-or/errors.json +14 -0
  134. data/spec/test_suite/negative/29-or/input.json +20 -0
  135. data/spec/test_suite/negative/29-or/rules.json +19 -0
  136. data/spec/test_suite/positive/01-required/input.json +7 -0
  137. data/spec/test_suite/positive/01-required/output.json +6 -0
  138. data/spec/test_suite/positive/01-required/rules.json +6 -0
  139. data/spec/test_suite/positive/02-not_empty/input.json +6 -0
  140. data/spec/test_suite/positive/02-not_empty/output.json +5 -0
  141. data/spec/test_suite/positive/02-not_empty/rules.json +6 -0
  142. data/spec/test_suite/positive/03-one_of/input.json +11 -0
  143. data/spec/test_suite/positive/03-one_of/output.json +10 -0
  144. data/spec/test_suite/positive/03-one_of/rules.json +10 -0
  145. data/spec/test_suite/positive/04-min_length/input.json +8 -0
  146. data/spec/test_suite/positive/04-min_length/output.json +7 -0
  147. data/spec/test_suite/positive/04-min_length/rules.json +8 -0
  148. data/spec/test_suite/positive/05-max_length/input.json +9 -0
  149. data/spec/test_suite/positive/05-max_length/output.json +8 -0
  150. data/spec/test_suite/positive/05-max_length/rules.json +9 -0
  151. data/spec/test_suite/positive/06-length_equal/input.json +8 -0
  152. data/spec/test_suite/positive/06-length_equal/output.json +7 -0
  153. data/spec/test_suite/positive/06-length_equal/rules.json +8 -0
  154. data/spec/test_suite/positive/07-length_between/input.json +9 -0
  155. data/spec/test_suite/positive/07-length_between/output.json +8 -0
  156. data/spec/test_suite/positive/07-length_between/rules.json +9 -0
  157. data/spec/test_suite/positive/08-like/input.json +8 -0
  158. data/spec/test_suite/positive/08-like/output.json +7 -0
  159. data/spec/test_suite/positive/08-like/rules.json +8 -0
  160. data/spec/test_suite/positive/09-integer/input.json +7 -0
  161. data/spec/test_suite/positive/09-integer/output.json +6 -0
  162. data/spec/test_suite/positive/09-integer/rules.json +7 -0
  163. data/spec/test_suite/positive/10-positive_integer/input.json +7 -0
  164. data/spec/test_suite/positive/10-positive_integer/output.json +6 -0
  165. data/spec/test_suite/positive/10-positive_integer/rules.json +6 -0
  166. data/spec/test_suite/positive/11-decimal/input.json +8 -0
  167. data/spec/test_suite/positive/11-decimal/output.json +7 -0
  168. data/spec/test_suite/positive/11-decimal/rules.json +7 -0
  169. data/spec/test_suite/positive/12-positive_decimal/input.json +8 -0
  170. data/spec/test_suite/positive/12-positive_decimal/output.json +7 -0
  171. data/spec/test_suite/positive/12-positive_decimal/rules.json +7 -0
  172. data/spec/test_suite/positive/13-max_number/input.json +7 -0
  173. data/spec/test_suite/positive/13-max_number/output.json +6 -0
  174. data/spec/test_suite/positive/13-max_number/rules.json +6 -0
  175. data/spec/test_suite/positive/14-min_number/input.json +7 -0
  176. data/spec/test_suite/positive/14-min_number/output.json +6 -0
  177. data/spec/test_suite/positive/14-min_number/rules.json +6 -0
  178. data/spec/test_suite/positive/15-number_between/input.json +8 -0
  179. data/spec/test_suite/positive/15-number_between/output.json +7 -0
  180. data/spec/test_suite/positive/15-number_between/rules.json +7 -0
  181. data/spec/test_suite/positive/16-email/input.json +7 -0
  182. data/spec/test_suite/positive/16-email/output.json +6 -0
  183. data/spec/test_suite/positive/16-email/rules.json +6 -0
  184. data/spec/test_suite/positive/17-equal_to_field/input.json +7 -0
  185. data/spec/test_suite/positive/17-equal_to_field/output.json +6 -0
  186. data/spec/test_suite/positive/17-equal_to_field/rules.json +6 -0
  187. data/spec/test_suite/positive/18-nested_object/input.json +15 -0
  188. data/spec/test_suite/positive/18-nested_object/output.json +12 -0
  189. data/spec/test_suite/positive/18-nested_object/rules.json +13 -0
  190. data/spec/test_suite/positive/19-list_of/input.json +7 -0
  191. data/spec/test_suite/positive/19-list_of/output.json +7 -0
  192. data/spec/test_suite/positive/19-list_of/rules.json +15 -0
  193. data/spec/test_suite/positive/20-list_of_objects/input.json +17 -0
  194. data/spec/test_suite/positive/20-list_of_objects/output.json +17 -0
  195. data/spec/test_suite/positive/20-list_of_objects/rules.json +10 -0
  196. data/spec/test_suite/positive/21-list_of_different_objects/input.json +22 -0
  197. data/spec/test_suite/positive/21-list_of_different_objects/output.json +21 -0
  198. data/spec/test_suite/positive/21-list_of_different_objects/rules.json +27 -0
  199. data/spec/test_suite/positive/22-not_empty_list/input.json +6 -0
  200. data/spec/test_suite/positive/22-not_empty_list/output.json +5 -0
  201. data/spec/test_suite/positive/22-not_empty_list/rules.json +5 -0
  202. data/spec/test_suite/positive/23-url/input.json +7 -0
  203. data/spec/test_suite/positive/23-url/output.json +6 -0
  204. data/spec/test_suite/positive/23-url/rules.json +6 -0
  205. data/spec/test_suite/positive/24-iso_date/input.json +9 -0
  206. data/spec/test_suite/positive/24-iso_date/output.json +8 -0
  207. data/spec/test_suite/positive/24-iso_date/rules.json +8 -0
  208. data/spec/test_suite/positive/25-eq/input.json +10 -0
  209. data/spec/test_suite/positive/25-eq/output.json +9 -0
  210. data/spec/test_suite/positive/25-eq/rules.json +9 -0
  211. data/spec/test_suite/positive/26-string/input.json +8 -0
  212. data/spec/test_suite/positive/26-string/output.json +7 -0
  213. data/spec/test_suite/positive/26-string/rules.json +7 -0
  214. data/spec/test_suite/positive/27-any_object/input.json +6 -0
  215. data/spec/test_suite/positive/27-any_object/output.json +6 -0
  216. data/spec/test_suite/positive/27-any_object/rules.json +7 -0
  217. data/spec/test_suite/positive/28-variable_object/input.json +19 -0
  218. data/spec/test_suite/positive/28-variable_object/output.json +18 -0
  219. data/spec/test_suite/positive/28-variable_object/rules.json +47 -0
  220. data/spec/test_suite/positive/29-or/input.json +25 -0
  221. data/spec/test_suite/positive/29-or/output.json +24 -0
  222. data/spec/test_suite/positive/29-or/rules.json +24 -0
  223. data/spec/test_suite/positive/30-trim/input.json +7 -0
  224. data/spec/test_suite/positive/30-trim/output.json +7 -0
  225. data/spec/test_suite/positive/30-trim/rules.json +7 -0
  226. data/spec/test_suite/positive/31-to_lc/input.json +8 -0
  227. data/spec/test_suite/positive/31-to_lc/output.json +8 -0
  228. data/spec/test_suite/positive/31-to_lc/rules.json +8 -0
  229. data/spec/test_suite/positive/32-to_uc/input.json +7 -0
  230. data/spec/test_suite/positive/32-to_uc/output.json +7 -0
  231. data/spec/test_suite/positive/32-to_uc/rules.json +7 -0
  232. data/spec/test_suite/positive/33-remove/input.json +5 -0
  233. data/spec/test_suite/positive/33-remove/output.json +5 -0
  234. data/spec/test_suite/positive/33-remove/rules.json +7 -0
  235. data/spec/test_suite/positive/34-leave_only/input.json +5 -0
  236. data/spec/test_suite/positive/34-leave_only/output.json +5 -0
  237. data/spec/test_suite/positive/34-leave_only/rules.json +7 -0
  238. data/spec/test_suite/positive/35-default/input.json +10 -0
  239. data/spec/test_suite/positive/35-default/output.json +12 -0
  240. data/spec/test_suite/positive/35-default/rules.json +12 -0
  241. metadata +532 -0
@@ -0,0 +1,10 @@
1
+ {
2
+ "age1": 32,
3
+ "age2": 33,
4
+ "age3": 35,
5
+ "age4": 36,
6
+ "age1_custom_error": 37,
7
+ "age2_custom_error": 38,
8
+ "age3_custom_error": 100,
9
+ "age4_custom_error": 110
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "age1": "adult_age",
3
+ "age2": ["adult_age"],
4
+ "age3": [ { "adult_age": [] } ],
5
+ "age4": { "adult_age": [] },
6
+ "age1_custom_error": "adult_age_with_custom_error",
7
+ "age2_custom_error": ["adult_age_with_custom_error"],
8
+ "age3_custom_error": [ { "adult_age_with_custom_error": [] } ],
9
+ "age4_custom_error": { "adult_age_with_custom_error": [] }
10
+ }
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "name": "address",
4
+ "rules": { "nested_object":{
5
+ "street": "required",
6
+ "zip": ["required", "positive_integer"],
7
+ "city": {"one_of": ["Kiev", "Kharkiv"] }
8
+ }}
9
+ },
10
+
11
+ {
12
+ "name": "address_with_custom_error",
13
+ "rules": { "nested_object":{
14
+ "street": "required",
15
+ "zip": ["required", "positive_integer"],
16
+ "city": {"one_of": ["Kiev", "Kharkiv"] }
17
+ }},
18
+ "error": "WRONG_ADDRESS"
19
+ }
20
+ ]
@@ -0,0 +1,13 @@
1
+ {
2
+ "address": {
3
+ "street": "My street",
4
+ "zip": 1232131,
5
+ "city": "Kiev"
6
+ },
7
+ "address_custom_error": {
8
+ "street": "My street",
9
+ "zip": "12312",
10
+ "city": "Kharkiv"
11
+ },
12
+ "extra_field": 12
13
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "address": {
3
+ "street": "My street",
4
+ "zip": 1232131,
5
+ "city": "Kiev"
6
+ },
7
+ "address_custom_error": {
8
+ "street": "My street",
9
+ "zip": 12312,
10
+ "city": "Kharkiv"
11
+ }
12
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "address": "address",
3
+ "address_custom_error": "address_with_custom_error"
4
+ }
@@ -0,0 +1,31 @@
1
+ [
2
+ {
3
+ "name": "adult_age",
4
+ "rules": ["positive_integer", {"min_number": 18}]
5
+ },
6
+
7
+ {
8
+ "name": "adult_age_with_custom_error",
9
+ "rules": ["positive_integer", {"min_number": 18}],
10
+ "error": "WRONG_AGE"
11
+ },
12
+
13
+ {
14
+ "name": "user",
15
+ "rules": { "nested_object":{
16
+ "name": "required",
17
+ "age1": "adult_age",
18
+ "age2": "adult_age_with_custom_error"
19
+ }}
20
+ },
21
+
22
+ {
23
+ "name": "user_with_custom_error",
24
+ "rules": { "nested_object":{
25
+ "name": "required",
26
+ "age1": "adult_age",
27
+ "age2": "adult_age_with_custom_error"
28
+ }},
29
+ "error": "WRONG_USER"
30
+ }
31
+ ]
@@ -0,0 +1,14 @@
1
+ {
2
+ "user": {
3
+ "name": "koorchik",
4
+ "age1": 20,
5
+ "age2": 40,
6
+ "extra_field": "som value"
7
+ },
8
+ "user_custom_error": {
9
+ "name": "koorchik",
10
+ "age1": 33,
11
+ "age2": 22
12
+ },
13
+ "extra_field": 12
14
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "user": {
3
+ "name": "koorchik",
4
+ "age1": 20,
5
+ "age2": 40
6
+ },
7
+ "user_custom_error": {
8
+ "name": "koorchik",
9
+ "age1": 33,
10
+ "age2": 22
11
+ }
12
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "user": "user",
3
+ "user_custom_error": ["user_with_custom_error"]
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "first_name": "REQUIRED",
3
+ "last_name": "REQUIRED",
4
+ "middle_name": "REQUIRED"
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "",
3
+ "last_name": null,
4
+ "age": "25",
5
+
6
+ "value_is_hash": {"test": 1},
7
+ "value_is_empty_hash": {},
8
+ "value_is_array": ["test", 1],
9
+ "value_is_empty_array": []
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "required",
3
+ "last_name": ["required"],
4
+ "middle_name": [ { "required": [] } ],
5
+
6
+ "value_is_hash": "required",
7
+ "value_is_empty_hash": "required",
8
+ "value_is_array": "required",
9
+ "value_is_empty_array": "required"
10
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "first_name": "CANNOT_BE_EMPTY"
3
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "",
3
+ "last_name": null,
4
+ "age": "25",
5
+
6
+ "value_is_hash": {"test": 1},
7
+ "value_is_empty_hash": {},
8
+ "value_is_array": ["test", 1],
9
+ "value_is_empty_array": []
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "not_empty",
3
+ "last_name": ["not_empty"],
4
+ "middle_name": [ { "not_empty": [] } ],
5
+
6
+ "value_is_hash": "not_empty",
7
+ "value_is_empty_hash": "not_empty",
8
+ "value_is_array": "not_empty",
9
+ "value_is_empty_array": "not_empty"
10
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "city1": "NOT_ALLOWED_VALUE",
3
+ "city2": "NOT_ALLOWED_VALUE",
4
+ "city3": "NOT_ALLOWED_VALUE",
5
+ "number1": "NOT_ALLOWED_VALUE",
6
+
7
+ "value_is_hash": "FORMAT_ERROR",
8
+ "value_is_empty_hash": "FORMAT_ERROR",
9
+ "value_is_array": "FORMAT_ERROR",
10
+ "value_is_empty_array": "FORMAT_ERROR"
11
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "city1": "New York",
3
+ "city2": "New York",
4
+ "city3": "New York",
5
+ "number1": "1.0",
6
+ "extra_city": "New York",
7
+
8
+ "value_is_hash": {"test": 1},
9
+ "value_is_empty_hash": {},
10
+ "value_is_array": ["test", 1],
11
+ "value_is_empty_array": []
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "city1": { "one_of": [["Moscow", "Kiev" ]] },
3
+ "city2": [{ "one_of": [["Moscow", "Kiev" ]] }],
4
+ "city3": { "one_of": ["Moscow", "Kiev"] },
5
+ "number1": { "one_of": [1, "1.00", "1"] },
6
+
7
+ "value_is_hash": { "one_of": [["Moscow", "Kiev" ]] },
8
+ "value_is_empty_hash": { "one_of": [["Moscow", "Kiev" ]] },
9
+ "value_is_array": { "one_of": [["Moscow", "Kiev" ]] },
10
+ "value_is_empty_array": { "one_of": [["Moscow", "Kiev" ]] }
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "TOO_SHORT",
3
+ "last_name": "TOO_SHORT",
4
+ "middle_name": "TOO_SHORT",
5
+
6
+ "value_is_hash": "FORMAT_ERROR",
7
+ "value_is_empty_hash": "FORMAT_ERROR",
8
+ "value_is_array": "FORMAT_ERROR",
9
+ "value_is_empty_array": "FORMAT_ERROR"
10
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "first_name": "Vasya",
3
+ "last_name": "Pupkin",
4
+ "middle_name": "Some name",
5
+ "empty_name": "",
6
+ "extra_name": "extra_name",
7
+
8
+ "value_is_hash": {"test": 1},
9
+ "value_is_empty_hash": {},
10
+ "value_is_array": ["test", 1],
11
+ "value_is_empty_array": []
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "first_name": { "min_length": 6 },
3
+ "last_name": { "min_length": [10] },
4
+ "middle_name": [{ "min_length": [10] }],
5
+ "empty_name": { "min_length": 3 },
6
+
7
+ "value_is_hash": { "min_length": 6 },
8
+ "value_is_empty_hash": { "min_length": 6 },
9
+ "value_is_array": { "min_length": 6 },
10
+ "value_is_empty_array": { "min_length": 6 }
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "TOO_LONG",
3
+ "last_name": "TOO_LONG",
4
+ "middle_name": "TOO_LONG",
5
+
6
+ "value_is_hash": "FORMAT_ERROR",
7
+ "value_is_empty_hash": "FORMAT_ERROR",
8
+ "value_is_array": "FORMAT_ERROR",
9
+ "value_is_empty_array": "FORMAT_ERROR"
10
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "first_name": "Vasya",
3
+ "last_name": "Pupkin",
4
+ "middle_name": "Some name",
5
+ "empty_name": "",
6
+ "extra_name": "extra_name",
7
+
8
+ "value_is_hash": {"test": 1},
9
+ "value_is_empty_hash": {},
10
+ "value_is_array": ["test", 1],
11
+ "value_is_empty_array": []
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "first_name": { "max_length": 4 },
3
+ "last_name": { "max_length": [5] },
4
+ "middle_name": [{ "max_length": [0] }],
5
+ "empty_name": { "max_length": 3 },
6
+
7
+ "value_is_hash": { "max_length": 4 },
8
+ "value_is_empty_hash": { "max_length": 4 },
9
+ "value_is_array": { "max_length": 4 },
10
+ "value_is_empty_array": { "max_length": 4 }
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "TOO_LONG",
3
+ "last_name": "TOO_SHORT",
4
+ "middle_name": "TOO_LONG",
5
+
6
+ "value_is_hash": "FORMAT_ERROR",
7
+ "value_is_empty_hash": "FORMAT_ERROR",
8
+ "value_is_array": "FORMAT_ERROR",
9
+ "value_is_empty_array": "FORMAT_ERROR"
10
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "first_name": "Vasya",
3
+ "last_name": "Pupkin",
4
+ "middle_name": "Some name",
5
+ "empty_name": "",
6
+ "extra_name": "extra_name",
7
+
8
+ "value_is_hash": {"test": 1},
9
+ "value_is_empty_hash": {},
10
+ "value_is_array": ["test", 1],
11
+ "value_is_empty_array": []
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "first_name": { "length_equal": 2 },
3
+ "last_name": { "length_equal": [7] },
4
+ "middle_name": [{ "length_equal": [3] }],
5
+ "empty_name": { "length_equal": 3 },
6
+
7
+ "value_is_hash": { "length_equal": 2 },
8
+ "value_is_empty_hash": { "length_equal": 2 },
9
+ "value_is_array": { "length_equal": 2 },
10
+ "value_is_empty_array": { "length_equal": 2 }
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "first_name": "TOO_SHORT",
3
+ "last_name": "TOO_LONG",
4
+ "middle_name": "TOO_LONG",
5
+
6
+ "value_is_hash": "FORMAT_ERROR",
7
+ "value_is_empty_hash": "FORMAT_ERROR",
8
+ "value_is_array": "FORMAT_ERROR",
9
+ "value_is_empty_array": "FORMAT_ERROR"
10
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "first_name": "Vasya",
3
+ "last_name": "Pupkin",
4
+ "middle_name": "Some name",
5
+ "empty_name": "",
6
+ "extra_name": "extra_name",
7
+
8
+ "value_is_hash": {"test": 1},
9
+ "value_is_empty_hash": {},
10
+ "value_is_array": ["test", 1],
11
+ "value_is_empty_array": []
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "first_name": { "length_between": [7, 10]},
3
+ "last_name": { "length_between": [4, 5] },
4
+ "middle_name": [{ "length_between": [2, 3] }],
5
+ "empty_name": { "length_between": [4, 10] },
6
+
7
+ "value_is_hash": { "length_between": [7, 10]},
8
+ "value_is_empty_hash": { "length_between": [7, 10]},
9
+ "value_is_array": { "length_between": [7, 10]},
10
+ "value_is_empty_array": { "length_between": [7, 10]}
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "first_name": "WRONG_FORMAT",
3
+ "last_name": "WRONG_FORMAT",
4
+ "middle_name": "WRONG_FORMAT",
5
+ "age": "WRONG_FORMAT",
6
+
7
+ "value_is_hash": "FORMAT_ERROR",
8
+ "value_is_empty_hash": "FORMAT_ERROR",
9
+ "value_is_array": "FORMAT_ERROR",
10
+ "value_is_empty_array": "FORMAT_ERROR"
11
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "first_name": "Vasya",
3
+ "last_name": "Pupkin",
4
+ "middle_name": "Ivanovich",
5
+ "age": "35",
6
+ "empty_name": "",
7
+ "extra_name": "extra_name",
8
+
9
+
10
+ "value_is_hash": {"test": 1},
11
+ "value_is_empty_hash": {},
12
+ "value_is_array": ["test", 1],
13
+ "value_is_empty_array": []
14
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "first_name": { "like": "[0-9]+" },
3
+ "last_name": { "like": ["^[A-Z]+$"] },
4
+ "middle_name": { "like": ["^[b-z]+$", "i"] },
5
+ "age": [{ "like": "^[a-z]+$" }],
6
+ "empty_name": { "like": "[A-Za-z]" },
7
+
8
+ "value_is_hash": { "like": "[0-9]+" },
9
+ "value_is_empty_hash": { "like": "[0-9]+" },
10
+ "value_is_array": { "like": "[0-9]+" },
11
+ "value_is_empty_array": { "like": "[0-9]+" }
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "number1": "NOT_INTEGER",
3
+ "number2": "NOT_INTEGER",
4
+ "number3": "NOT_INTEGER",
5
+
6
+ "value_is_string": "NOT_INTEGER",
7
+ "value_is_hash": "FORMAT_ERROR",
8
+ "value_is_empty_hash": "FORMAT_ERROR",
9
+ "value_is_array": "FORMAT_ERROR",
10
+ "value_is_empty_array": "FORMAT_ERROR"
11
+ }