ruby-livr 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +45 -0
- data/Readme.md +119 -0
- data/lib/livr.rb +60 -0
- data/lib/livr/aliased_rule.rb +26 -0
- data/lib/livr/rule.rb +21 -0
- data/lib/livr/rules/common.rb +35 -0
- data/lib/livr/rules/meta.rb +200 -0
- data/lib/livr/rules/modifiers.rb +68 -0
- data/lib/livr/rules/numeric.rb +136 -0
- data/lib/livr/rules/special.rb +65 -0
- data/lib/livr/rules/string.rb +150 -0
- data/lib/livr/validator.rb +134 -0
- data/ruby-livr.gemspec +19 -0
- data/spec/01-test_suite_spec.rb +34 -0
- data/spec/02-aliases_spec.rb +21 -0
- data/spec/03-auto_trim_spec.rb +56 -0
- data/spec/04-custom_filters_spec.rb +54 -0
- data/spec/05-rules_replacement_spec.rb +67 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/test_suite/aliases_negative/01-adult_age/aliases.json +12 -0
- data/spec/test_suite/aliases_negative/01-adult_age/errors.json +6 -0
- data/spec/test_suite/aliases_negative/01-adult_age/input.json +11 -0
- data/spec/test_suite/aliases_negative/01-adult_age/rules.json +10 -0
- data/spec/test_suite/aliases_negative/02-address/aliases.json +20 -0
- data/spec/test_suite/aliases_negative/02-address/errors.json +8 -0
- data/spec/test_suite/aliases_negative/02-address/input.json +13 -0
- data/spec/test_suite/aliases_negative/02-address/rules.json +4 -0
- data/spec/test_suite/aliases_negative/03-adult_age_in_user/aliases.json +31 -0
- data/spec/test_suite/aliases_negative/03-adult_age_in_user/errors.json +8 -0
- data/spec/test_suite/aliases_negative/03-adult_age_in_user/input.json +14 -0
- data/spec/test_suite/aliases_negative/03-adult_age_in_user/rules.json +4 -0
- data/spec/test_suite/aliases_positive/01-adult_age/aliases.json +12 -0
- data/spec/test_suite/aliases_positive/01-adult_age/input.json +11 -0
- data/spec/test_suite/aliases_positive/01-adult_age/output.json +10 -0
- data/spec/test_suite/aliases_positive/01-adult_age/rules.json +10 -0
- data/spec/test_suite/aliases_positive/02-address/aliases.json +20 -0
- data/spec/test_suite/aliases_positive/02-address/input.json +13 -0
- data/spec/test_suite/aliases_positive/02-address/output.json +12 -0
- data/spec/test_suite/aliases_positive/02-address/rules.json +4 -0
- data/spec/test_suite/aliases_positive/03-adult_age_in_user/aliases.json +31 -0
- data/spec/test_suite/aliases_positive/03-adult_age_in_user/input.json +14 -0
- data/spec/test_suite/aliases_positive/03-adult_age_in_user/output.json +12 -0
- data/spec/test_suite/aliases_positive/03-adult_age_in_user/rules.json +4 -0
- data/spec/test_suite/negative/01-required/errors.json +5 -0
- data/spec/test_suite/negative/01-required/input.json +10 -0
- data/spec/test_suite/negative/01-required/rules.json +10 -0
- data/spec/test_suite/negative/02-not_empty/errors.json +3 -0
- data/spec/test_suite/negative/02-not_empty/input.json +10 -0
- data/spec/test_suite/negative/02-not_empty/rules.json +10 -0
- data/spec/test_suite/negative/03-one_of/errors.json +11 -0
- data/spec/test_suite/negative/03-one_of/input.json +12 -0
- data/spec/test_suite/negative/03-one_of/rules.json +11 -0
- data/spec/test_suite/negative/04-min_length/errors.json +10 -0
- data/spec/test_suite/negative/04-min_length/input.json +12 -0
- data/spec/test_suite/negative/04-min_length/rules.json +11 -0
- data/spec/test_suite/negative/05-max_length/errors.json +10 -0
- data/spec/test_suite/negative/05-max_length/input.json +12 -0
- data/spec/test_suite/negative/05-max_length/rules.json +11 -0
- data/spec/test_suite/negative/06-length_equal/errors.json +10 -0
- data/spec/test_suite/negative/06-length_equal/input.json +12 -0
- data/spec/test_suite/negative/06-length_equal/rules.json +11 -0
- data/spec/test_suite/negative/07-length_between/errors.json +10 -0
- data/spec/test_suite/negative/07-length_between/input.json +12 -0
- data/spec/test_suite/negative/07-length_between/rules.json +11 -0
- data/spec/test_suite/negative/08-like/errors.json +11 -0
- data/spec/test_suite/negative/08-like/input.json +14 -0
- data/spec/test_suite/negative/08-like/rules.json +12 -0
- data/spec/test_suite/negative/09-integer/errors.json +11 -0
- data/spec/test_suite/negative/09-integer/input.json +13 -0
- data/spec/test_suite/negative/09-integer/rules.json +12 -0
- data/spec/test_suite/negative/10-positive_integer/errors.json +11 -0
- data/spec/test_suite/negative/10-positive_integer/input.json +13 -0
- data/spec/test_suite/negative/10-positive_integer/rules.json +12 -0
- data/spec/test_suite/negative/11-decimal/errors.json +11 -0
- data/spec/test_suite/negative/11-decimal/input.json +13 -0
- data/spec/test_suite/negative/11-decimal/rules.json +12 -0
- data/spec/test_suite/negative/12-positive_decimal/errors.json +11 -0
- data/spec/test_suite/negative/12-positive_decimal/input.json +13 -0
- data/spec/test_suite/negative/12-positive_decimal/rules.json +12 -0
- data/spec/test_suite/negative/13-max_number/errors.json +10 -0
- data/spec/test_suite/negative/13-max_number/input.json +12 -0
- data/spec/test_suite/negative/13-max_number/rules.json +11 -0
- data/spec/test_suite/negative/14-min_number/errors.json +11 -0
- data/spec/test_suite/negative/14-min_number/input.json +13 -0
- data/spec/test_suite/negative/14-min_number/rules.json +12 -0
- data/spec/test_suite/negative/15-number_beetween/errors.json +12 -0
- data/spec/test_suite/negative/15-number_beetween/input.json +14 -0
- data/spec/test_suite/negative/15-number_beetween/rules.json +13 -0
- data/spec/test_suite/negative/16-email/errors.json +12 -0
- data/spec/test_suite/negative/16-email/input.json +14 -0
- data/spec/test_suite/negative/16-email/rules.json +13 -0
- data/spec/test_suite/negative/17-equal_to_field/errors.json +10 -0
- data/spec/test_suite/negative/17-equal_to_field/input.json +12 -0
- data/spec/test_suite/negative/17-equal_to_field/rules.json +11 -0
- data/spec/test_suite/negative/18-nested_object/errors.json +9 -0
- data/spec/test_suite/negative/18-nested_object/input.json +9 -0
- data/spec/test_suite/negative/18-nested_object/rules.json +9 -0
- data/spec/test_suite/negative/19-list_of/errors.json +6 -0
- data/spec/test_suite/negative/19-list_of/input.json +6 -0
- data/spec/test_suite/negative/19-list_of/rules.json +14 -0
- data/spec/test_suite/negative/20-list_of_objects/errors.json +14 -0
- data/spec/test_suite/negative/20-list_of_objects/input.json +18 -0
- data/spec/test_suite/negative/20-list_of_objects/rules.json +7 -0
- data/spec/test_suite/negative/21-list_of_different_objects/errors.json +17 -0
- data/spec/test_suite/negative/21-list_of_different_objects/input.json +26 -0
- data/spec/test_suite/negative/21-list_of_different_objects/rules.json +17 -0
- data/spec/test_suite/negative/22-not_empty_list/errors.json +7 -0
- data/spec/test_suite/negative/22-not_empty_list/input.json +6 -0
- data/spec/test_suite/negative/22-not_empty_list/rules.json +7 -0
- data/spec/test_suite/negative/23-url/errors.json +10 -0
- data/spec/test_suite/negative/23-url/input.json +12 -0
- data/spec/test_suite/negative/23-url/rules.json +11 -0
- data/spec/test_suite/negative/24-iso_date/errors.json +11 -0
- data/spec/test_suite/negative/24-iso_date/input.json +13 -0
- data/spec/test_suite/negative/24-iso_date/rules.json +12 -0
- data/spec/test_suite/negative/25-eq/errors.json +13 -0
- data/spec/test_suite/negative/25-eq/input.json +14 -0
- data/spec/test_suite/negative/25-eq/rules.json +13 -0
- data/spec/test_suite/negative/26-string/errors.json +6 -0
- data/spec/test_suite/negative/26-string/input.json +6 -0
- data/spec/test_suite/negative/26-string/rules.json +6 -0
- data/spec/test_suite/negative/27-any_object/errors.json +6 -0
- data/spec/test_suite/negative/27-any_object/input.json +6 -0
- data/spec/test_suite/negative/27-any_object/rules.json +6 -0
- data/spec/test_suite/negative/28-variable_object/errors.json +15 -0
- data/spec/test_suite/negative/28-variable_object/input.json +24 -0
- data/spec/test_suite/negative/28-variable_object/rules.json +77 -0
- data/spec/test_suite/negative/29-or/errors.json +14 -0
- data/spec/test_suite/negative/29-or/input.json +20 -0
- data/spec/test_suite/negative/29-or/rules.json +19 -0
- data/spec/test_suite/positive/01-required/input.json +7 -0
- data/spec/test_suite/positive/01-required/output.json +6 -0
- data/spec/test_suite/positive/01-required/rules.json +6 -0
- data/spec/test_suite/positive/02-not_empty/input.json +6 -0
- data/spec/test_suite/positive/02-not_empty/output.json +5 -0
- data/spec/test_suite/positive/02-not_empty/rules.json +6 -0
- data/spec/test_suite/positive/03-one_of/input.json +11 -0
- data/spec/test_suite/positive/03-one_of/output.json +10 -0
- data/spec/test_suite/positive/03-one_of/rules.json +10 -0
- data/spec/test_suite/positive/04-min_length/input.json +8 -0
- data/spec/test_suite/positive/04-min_length/output.json +7 -0
- data/spec/test_suite/positive/04-min_length/rules.json +8 -0
- data/spec/test_suite/positive/05-max_length/input.json +9 -0
- data/spec/test_suite/positive/05-max_length/output.json +8 -0
- data/spec/test_suite/positive/05-max_length/rules.json +9 -0
- data/spec/test_suite/positive/06-length_equal/input.json +8 -0
- data/spec/test_suite/positive/06-length_equal/output.json +7 -0
- data/spec/test_suite/positive/06-length_equal/rules.json +8 -0
- data/spec/test_suite/positive/07-length_between/input.json +9 -0
- data/spec/test_suite/positive/07-length_between/output.json +8 -0
- data/spec/test_suite/positive/07-length_between/rules.json +9 -0
- data/spec/test_suite/positive/08-like/input.json +8 -0
- data/spec/test_suite/positive/08-like/output.json +7 -0
- data/spec/test_suite/positive/08-like/rules.json +8 -0
- data/spec/test_suite/positive/09-integer/input.json +7 -0
- data/spec/test_suite/positive/09-integer/output.json +6 -0
- data/spec/test_suite/positive/09-integer/rules.json +7 -0
- data/spec/test_suite/positive/10-positive_integer/input.json +7 -0
- data/spec/test_suite/positive/10-positive_integer/output.json +6 -0
- data/spec/test_suite/positive/10-positive_integer/rules.json +6 -0
- data/spec/test_suite/positive/11-decimal/input.json +8 -0
- data/spec/test_suite/positive/11-decimal/output.json +7 -0
- data/spec/test_suite/positive/11-decimal/rules.json +7 -0
- data/spec/test_suite/positive/12-positive_decimal/input.json +8 -0
- data/spec/test_suite/positive/12-positive_decimal/output.json +7 -0
- data/spec/test_suite/positive/12-positive_decimal/rules.json +7 -0
- data/spec/test_suite/positive/13-max_number/input.json +7 -0
- data/spec/test_suite/positive/13-max_number/output.json +6 -0
- data/spec/test_suite/positive/13-max_number/rules.json +6 -0
- data/spec/test_suite/positive/14-min_number/input.json +7 -0
- data/spec/test_suite/positive/14-min_number/output.json +6 -0
- data/spec/test_suite/positive/14-min_number/rules.json +6 -0
- data/spec/test_suite/positive/15-number_between/input.json +8 -0
- data/spec/test_suite/positive/15-number_between/output.json +7 -0
- data/spec/test_suite/positive/15-number_between/rules.json +7 -0
- data/spec/test_suite/positive/16-email/input.json +7 -0
- data/spec/test_suite/positive/16-email/output.json +6 -0
- data/spec/test_suite/positive/16-email/rules.json +6 -0
- data/spec/test_suite/positive/17-equal_to_field/input.json +7 -0
- data/spec/test_suite/positive/17-equal_to_field/output.json +6 -0
- data/spec/test_suite/positive/17-equal_to_field/rules.json +6 -0
- data/spec/test_suite/positive/18-nested_object/input.json +15 -0
- data/spec/test_suite/positive/18-nested_object/output.json +12 -0
- data/spec/test_suite/positive/18-nested_object/rules.json +13 -0
- data/spec/test_suite/positive/19-list_of/input.json +7 -0
- data/spec/test_suite/positive/19-list_of/output.json +7 -0
- data/spec/test_suite/positive/19-list_of/rules.json +15 -0
- data/spec/test_suite/positive/20-list_of_objects/input.json +17 -0
- data/spec/test_suite/positive/20-list_of_objects/output.json +17 -0
- data/spec/test_suite/positive/20-list_of_objects/rules.json +10 -0
- data/spec/test_suite/positive/21-list_of_different_objects/input.json +22 -0
- data/spec/test_suite/positive/21-list_of_different_objects/output.json +21 -0
- data/spec/test_suite/positive/21-list_of_different_objects/rules.json +27 -0
- data/spec/test_suite/positive/22-not_empty_list/input.json +6 -0
- data/spec/test_suite/positive/22-not_empty_list/output.json +5 -0
- data/spec/test_suite/positive/22-not_empty_list/rules.json +5 -0
- data/spec/test_suite/positive/23-url/input.json +7 -0
- data/spec/test_suite/positive/23-url/output.json +6 -0
- data/spec/test_suite/positive/23-url/rules.json +6 -0
- data/spec/test_suite/positive/24-iso_date/input.json +9 -0
- data/spec/test_suite/positive/24-iso_date/output.json +8 -0
- data/spec/test_suite/positive/24-iso_date/rules.json +8 -0
- data/spec/test_suite/positive/25-eq/input.json +10 -0
- data/spec/test_suite/positive/25-eq/output.json +9 -0
- data/spec/test_suite/positive/25-eq/rules.json +9 -0
- data/spec/test_suite/positive/26-string/input.json +8 -0
- data/spec/test_suite/positive/26-string/output.json +7 -0
- data/spec/test_suite/positive/26-string/rules.json +7 -0
- data/spec/test_suite/positive/27-any_object/input.json +6 -0
- data/spec/test_suite/positive/27-any_object/output.json +6 -0
- data/spec/test_suite/positive/27-any_object/rules.json +7 -0
- data/spec/test_suite/positive/28-variable_object/input.json +19 -0
- data/spec/test_suite/positive/28-variable_object/output.json +18 -0
- data/spec/test_suite/positive/28-variable_object/rules.json +47 -0
- data/spec/test_suite/positive/29-or/input.json +25 -0
- data/spec/test_suite/positive/29-or/output.json +24 -0
- data/spec/test_suite/positive/29-or/rules.json +24 -0
- data/spec/test_suite/positive/30-trim/input.json +7 -0
- data/spec/test_suite/positive/30-trim/output.json +7 -0
- data/spec/test_suite/positive/30-trim/rules.json +7 -0
- data/spec/test_suite/positive/31-to_lc/input.json +8 -0
- data/spec/test_suite/positive/31-to_lc/output.json +8 -0
- data/spec/test_suite/positive/31-to_lc/rules.json +8 -0
- data/spec/test_suite/positive/32-to_uc/input.json +7 -0
- data/spec/test_suite/positive/32-to_uc/output.json +7 -0
- data/spec/test_suite/positive/32-to_uc/rules.json +7 -0
- data/spec/test_suite/positive/33-remove/input.json +5 -0
- data/spec/test_suite/positive/33-remove/output.json +5 -0
- data/spec/test_suite/positive/33-remove/rules.json +7 -0
- data/spec/test_suite/positive/34-leave_only/input.json +5 -0
- data/spec/test_suite/positive/34-leave_only/output.json +5 -0
- data/spec/test_suite/positive/34-leave_only/rules.json +7 -0
- data/spec/test_suite/positive/35-default/input.json +10 -0
- data/spec/test_suite/positive/35-default/output.json +12 -0
- data/spec/test_suite/positive/35-default/rules.json +12 -0
- metadata +532 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"order_id": "NOT_POSITIVE_INTEGER",
|
3
|
+
"products": [
|
4
|
+
{
|
5
|
+
"material_id": "NOT_POSITIVE_INTEGER",
|
6
|
+
"quantity": "REQUIRED"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"warehouse_id": "NOT_POSITIVE_INTEGER"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"name": "TOO_LONG"
|
13
|
+
},
|
14
|
+
"FORMAT_ERROR",
|
15
|
+
"FORMAT_ERROR"
|
16
|
+
]
|
17
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"order_id": "-10",
|
3
|
+
"products": [
|
4
|
+
{
|
5
|
+
"product_type": "material",
|
6
|
+
"material_id": 0,
|
7
|
+
"quantity": ""
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"product_type": "material",
|
11
|
+
"material_id": 100,
|
12
|
+
"quantity": 10,
|
13
|
+
"warehouse_id": -100
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"product_type": "service",
|
17
|
+
"name": "Very Long Name"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"product_type": "wrongtype",
|
21
|
+
"name": "Wrongtype"
|
22
|
+
},
|
23
|
+
"Some Wrong Data"
|
24
|
+
],
|
25
|
+
"users": "not an array"
|
26
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"order_id": ["required", "positive_integer"],
|
3
|
+
"products": ["required", { "list_of_different_objects": [
|
4
|
+
"product_type", {
|
5
|
+
"material": {
|
6
|
+
"product_type": "required",
|
7
|
+
"material_id": ["required", "positive_integer"],
|
8
|
+
"quantity": ["required", {"min_number": 1} ],
|
9
|
+
"warehouse_id": "positive_integer"
|
10
|
+
},
|
11
|
+
"service": {
|
12
|
+
"product_type": "required",
|
13
|
+
"name": ["required", {"max_length": 10} ]
|
14
|
+
}
|
15
|
+
}
|
16
|
+
]}]
|
17
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"url1": "www.google.com",
|
3
|
+
"url2": "ftp://facebook.com",
|
4
|
+
"url3": "http://g_oogle.com",
|
5
|
+
"empty_field": "",
|
6
|
+
"extra_field": "aaaa",
|
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
|
+
"iso_date1": "WRONG_DATE",
|
3
|
+
"iso_date2": "WRONG_DATE",
|
4
|
+
"iso_date3": "WRONG_DATE",
|
5
|
+
"like_iso_date": "WRONG_DATE",
|
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,13 @@
|
|
1
|
+
{
|
2
|
+
"iso_date1": "2014-13-10",
|
3
|
+
"iso_date2": "2011-02-29",
|
4
|
+
"iso_date3": "2014-10-10T22:22",
|
5
|
+
"like_iso_date":"aaaa-bb-cc",
|
6
|
+
"empty_field": "",
|
7
|
+
"extra_field": "aaaa",
|
8
|
+
|
9
|
+
"value_is_hash": {"test": 1},
|
10
|
+
"value_is_empty_hash": {},
|
11
|
+
"value_is_array": ["test", 1],
|
12
|
+
"value_is_empty_array": []
|
13
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"iso_date1": "iso_date",
|
3
|
+
"iso_date2": { "iso_date": [] },
|
4
|
+
"iso_date3": [ { "iso_date": [] } ],
|
5
|
+
"like_iso_date": [ { "iso_date": [] } ],
|
6
|
+
"empty_field": "iso_date",
|
7
|
+
|
8
|
+
"value_is_hash": "iso_date",
|
9
|
+
"value_is_empty_hash": "iso_date",
|
10
|
+
"value_is_array": "iso_date",
|
11
|
+
"value_is_empty_array": "iso_date"
|
12
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"city1": "NOT_ALLOWED_VALUE",
|
3
|
+
"city2": "NOT_ALLOWED_VALUE",
|
4
|
+
"city3": "NOT_ALLOWED_VALUE",
|
5
|
+
"number1": "NOT_ALLOWED_VALUE",
|
6
|
+
"number2": "NOT_ALLOWED_VALUE",
|
7
|
+
"number3": "NOT_ALLOWED_VALUE",
|
8
|
+
"empty_string": "NOT_ALLOWED_VALUE",
|
9
|
+
"value_is_hash": "FORMAT_ERROR",
|
10
|
+
"value_is_empty_hash": "FORMAT_ERROR",
|
11
|
+
"value_is_array": "FORMAT_ERROR",
|
12
|
+
"value_is_empty_array": "FORMAT_ERROR"
|
13
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"city1": "New York",
|
3
|
+
"city2": "New York",
|
4
|
+
"city3": "New York",
|
5
|
+
"number1": "1.0",
|
6
|
+
"number2": "asdasd",
|
7
|
+
"number3": " _",
|
8
|
+
"empty_string": " ",
|
9
|
+
"extra_city": "New York",
|
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,13 @@
|
|
1
|
+
{
|
2
|
+
"city1": { "eq": "Moscow" },
|
3
|
+
"city2": [{ "eq": "Moscow" }],
|
4
|
+
"city3": { "eq": "Kiev" },
|
5
|
+
"number1": { "eq": 1 },
|
6
|
+
"number2": { "eq": 1 },
|
7
|
+
"number3": { "eq": 1.2 },
|
8
|
+
"empty_string": {"eq": 1 },
|
9
|
+
"value_is_hash": { "eq": "Moscow" },
|
10
|
+
"value_is_empty_hash": { "eq": "Moscow" },
|
11
|
+
"value_is_array": { "eq": "Moscow" },
|
12
|
+
"value_is_empty_array": { "eq": "Moscow" }
|
13
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"order_id": "NOT_POSITIVE_INTEGER",
|
3
|
+
"product1": {
|
4
|
+
"material_id": "NOT_POSITIVE_INTEGER",
|
5
|
+
"quantity": "REQUIRED"
|
6
|
+
},
|
7
|
+
"product2": {
|
8
|
+
"warehouse_id": "NOT_POSITIVE_INTEGER"
|
9
|
+
},
|
10
|
+
"product3": {
|
11
|
+
"name": "TOO_LONG"
|
12
|
+
},
|
13
|
+
"product4": "FORMAT_ERROR",
|
14
|
+
"product5": "FORMAT_ERROR"
|
15
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"order_id": "-10",
|
3
|
+
"product1": {
|
4
|
+
"product_type": "material",
|
5
|
+
"material_id": 0,
|
6
|
+
"quantity": ""
|
7
|
+
},
|
8
|
+
"product2": {
|
9
|
+
"product_type": "material",
|
10
|
+
"material_id": 100,
|
11
|
+
"quantity": 10,
|
12
|
+
"warehouse_id": -100
|
13
|
+
},
|
14
|
+
"product3": {
|
15
|
+
"product_type": "service",
|
16
|
+
"name": "Very Long Name"
|
17
|
+
},
|
18
|
+
"product4": {
|
19
|
+
"product_type": "wrongtype",
|
20
|
+
"name": "Wrongtype"
|
21
|
+
},
|
22
|
+
"product5": "Some Wrong Data",
|
23
|
+
"users": "not an array"
|
24
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
{
|
2
|
+
"order_id": ["required", "positive_integer"],
|
3
|
+
"product1": ["required", { "variable_object": [
|
4
|
+
"product_type", {
|
5
|
+
"material": {
|
6
|
+
"product_type": "required",
|
7
|
+
"material_id": ["required", "positive_integer"],
|
8
|
+
"quantity": ["required", {"min_number": 1} ],
|
9
|
+
"warehouse_id": "positive_integer"
|
10
|
+
},
|
11
|
+
"service": {
|
12
|
+
"product_type": "required",
|
13
|
+
"name": ["required", {"max_length": 10} ]
|
14
|
+
}
|
15
|
+
}
|
16
|
+
]}],
|
17
|
+
|
18
|
+
"product2": ["required", { "variable_object": [
|
19
|
+
"product_type", {
|
20
|
+
"material": {
|
21
|
+
"product_type": "required",
|
22
|
+
"material_id": ["required", "positive_integer"],
|
23
|
+
"quantity": ["required", {"min_number": 1} ],
|
24
|
+
"warehouse_id": "positive_integer"
|
25
|
+
},
|
26
|
+
"service": {
|
27
|
+
"product_type": "required",
|
28
|
+
"name": ["required", {"max_length": 10} ]
|
29
|
+
}
|
30
|
+
}
|
31
|
+
]}],
|
32
|
+
|
33
|
+
"product3": ["required", { "variable_object": [
|
34
|
+
"product_type", {
|
35
|
+
"material": {
|
36
|
+
"product_type": "required",
|
37
|
+
"material_id": ["required", "positive_integer"],
|
38
|
+
"quantity": ["required", {"min_number": 1} ],
|
39
|
+
"warehouse_id": "positive_integer"
|
40
|
+
},
|
41
|
+
"service": {
|
42
|
+
"product_type": "required",
|
43
|
+
"name": ["required", {"max_length": 10} ]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
]}],
|
47
|
+
|
48
|
+
"product4": ["required", { "variable_object": [
|
49
|
+
"product_type", {
|
50
|
+
"material": {
|
51
|
+
"product_type": "required",
|
52
|
+
"material_id": ["required", "positive_integer"],
|
53
|
+
"quantity": ["required", {"min_number": 1} ],
|
54
|
+
"warehouse_id": "positive_integer"
|
55
|
+
},
|
56
|
+
"service": {
|
57
|
+
"product_type": "required",
|
58
|
+
"name": ["required", {"max_length": 10} ]
|
59
|
+
}
|
60
|
+
}
|
61
|
+
]}],
|
62
|
+
|
63
|
+
"product5": ["required", { "variable_object": [
|
64
|
+
"product_type", {
|
65
|
+
"material": {
|
66
|
+
"product_type": "required",
|
67
|
+
"material_id": ["required", "positive_integer"],
|
68
|
+
"quantity": ["required", {"min_number": 1} ],
|
69
|
+
"warehouse_id": "positive_integer"
|
70
|
+
},
|
71
|
+
"service": {
|
72
|
+
"product_type": "required",
|
73
|
+
"name": ["required", {"max_length": 10} ]
|
74
|
+
}
|
75
|
+
}
|
76
|
+
]}]
|
77
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"id1-1": "Usermail.com",
|
3
|
+
"id2-1": "Usermail.com",
|
4
|
+
"id3-1": "Usermail.com",
|
5
|
+
|
6
|
+
"products": [
|
7
|
+
{
|
8
|
+
"product_type": "material",
|
9
|
+
"material_id": 123,
|
10
|
+
"quantity": 10,
|
11
|
+
"warehouse_id": -321
|
12
|
+
},
|
13
|
+
|
14
|
+
{
|
15
|
+
"product_type": "service",
|
16
|
+
"name": "",
|
17
|
+
"extra_field": "some data"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"id1-1": { "or": ["email", "positive_integer" ] },
|
3
|
+
"id2-1": [{ "or": ["email", "positive_integer" ] }, "to_lc"],
|
4
|
+
"id3-1": { "or": [{"min_length": 15}, ["email", "to_lc"] ] },
|
5
|
+
|
6
|
+
"products": {"list_of": { "or": [
|
7
|
+
{"nested_object": {
|
8
|
+
"product_type": ["required", {"eq": "material"}],
|
9
|
+
"material_id": ["required", "positive_integer"],
|
10
|
+
"quantity": ["required", {"min_number": 1} ],
|
11
|
+
"warehouse_id": "positive_integer"
|
12
|
+
}},
|
13
|
+
|
14
|
+
{"nested_object": {
|
15
|
+
"product_type": ["required", {"eq": "service"}],
|
16
|
+
"name": ["required", {"max_length": 20} ]
|
17
|
+
}}
|
18
|
+
]}}
|
19
|
+
}
|