Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow empty values with minlength & allowed rules #238

Merged
merged 7 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions assets/specs/module-functions/schema-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ schema:
schema:
SiteID:
required: true
allowed:
- Ottawa Site
- Montreal Site
anyof:
- allowed:
- Ottawa Site
- Montreal Site
empty: true
meta:
- ruleID: missing_mandatory_column
meta:
Expand Down
14 changes: 8 additions & 6 deletions assets/specs/module-functions/schema-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ schema:
type: dict
schema:
collection:
allowed:
- comp3h
- comp8h
- flowPr
- comp3
- comp3dep
anyof:
- allowed:
- comp3h
- comp8h
- flowPr
- comp3
- comp3dep
empty: true
meta:
- ruleID: invalid_category
meta:
Expand Down
7 changes: 6 additions & 1 deletion assets/specs/module-functions/schema-additions-1.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"Site": {
"SiteID": {
"allowed": ["Ottawa Site", "Montreal Site"]
"anyof": [
{
"allowed": ["Ottawa Site", "Montreal Site"],
"empty": true
}
]
}
}
}
6 changes: 5 additions & 1 deletion assets/specs/module-functions/schema-additions-2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"samples": {
"collection": {
"allowed": ["comp3", "comp3dep"]
"anyof": [
{
"allowed": ["comp3", "comp3dep"]
}
]
}
}
}
6 changes: 6 additions & 0 deletions assets/validation-rules/empty/dataset-allowed.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
siteID,allowedField
1,
2,""
3," "
4,NA
5,a
7 changes: 7 additions & 0 deletions assets/validation-rules/empty/dataset-minlength.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
siteID,minlengthField
1,
2,""
3," "
4,NA
5,x
6,xxxxx
66 changes: 66 additions & 0 deletions assets/validation-rules/empty/error-report-allowed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"warnings": [
{
"columnName": "allowedField",
"invalidValue": "",
"message": "missing_values_found rule triggered in table sites, column allowedField, row(s) 1: Empty string found",
"row": {"allowedField": "", "siteID": "1"},
"rowNumber": 1,
"tableName": "sites",
"validationRuleFields": [],
"warningType": "missing_values_found"
},
{
"columnName": "allowedField",
"invalidValue": "",
"message": "missing_values_found rule triggered in table sites, column allowedField, row(s) 2: Empty string found",
"row": {"allowedField": "", "siteID": "2"},
"rowNumber": 2,
"tableName": "sites",
"validationRuleFields": [],
"warningType": "missing_values_found"
},
{
"columnName": "allowedField",
"invalidValue": " ",
"message": "missing_values_found rule triggered in table sites, column allowedField, row(s) 3: Missing value \" \"",
"row": {"allowedField": " ", "siteID": "3"},
"rowNumber": 3,
"tableName": "sites",
"validationRuleFields": [],
"warningType": "missing_values_found"
},
{
"columnName": "allowedField",
"invalidValue": "NA",
"message": "missing_values_found rule triggered in table sites, column allowedField, row(s) 4: Missing value \"NA\"",
"row": {"allowedField": "NA", "siteID": "4"},
"rowNumber": 4,
"tableName": "sites",
"validationRuleFields": [],
"warningType": "missing_values_found"
}
],
"errors": [
{
"columnName": "allowedField",
"errorType": "invalid_category",
"invalidValue": " ",
"message": "invalid_category rule violated in table sites, column allowedField, row(s) 3: Invalid category \" \"",
"row": {"allowedField": " ", "siteID": "3"},
"rowNumber": 3,
"tableName": "sites",
"validationRuleFields": []
},
{
"columnName": "allowedField",
"errorType": "invalid_category",
"invalidValue": "NA",
"message": "invalid_category rule violated in table sites, column allowedField, row(s) 4: Invalid category \"NA\"",
"row": {"allowedField": "NA", "siteID": "4"},
"rowNumber": 4,
"tableName": "sites",
"validationRuleFields": []
}
]
}
75 changes: 75 additions & 0 deletions assets/validation-rules/empty/error-report-minlength.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"warnings": [
{
"warningType": "missing_values_found",
"tableName": "sites",
"columnName": "minlengthField",
"validationRuleFields": [],
"message": "missing_values_found rule triggered in table sites, column minlengthField, row(s) 1: Empty string found",
"rowNumber": 1,
"row": {"siteID": "1", "minlengthField": ""},
"invalidValue": ""
},
{
"warningType": "missing_values_found",
"tableName": "sites",
"columnName": "minlengthField",
"validationRuleFields": [],
"message": "missing_values_found rule triggered in table sites, column minlengthField, row(s) 2: Empty string found",
"rowNumber": 2,
"row": {"siteID": "2", "minlengthField": ""}, "invalidValue": ""
},
{
"warningType": "missing_values_found",
"tableName": "sites",
"columnName": "minlengthField",
"validationRuleFields": [],
"message": "missing_values_found rule triggered in table sites, column minlengthField, row(s) 3: Missing value \" \"",
"rowNumber": 3,
"row": {"siteID": "3", "minlengthField": " "},
"invalidValue": " "
},
{
"warningType": "missing_values_found",
"tableName": "sites",
"columnName": "minlengthField",
"validationRuleFields": [],
"message": "missing_values_found rule triggered in table sites, column minlengthField, row(s) 4: Missing value \"NA\"",
"rowNumber": 4,
"row": {"siteID": "4", "minlengthField": "NA"},
"invalidValue": "NA"
}
],
"errors": [
{
"errorType": "less_than_min_length",
"tableName": "sites",
"columnName": "minlengthField",
"validationRuleFields": [],
"message": "less_than_min_length rule violated in table sites, column minlengthField, row(s) 3: Value \" \" (of length 3) is less than the min length of \"5\"",
"rowNumber": 3,
"row": {"siteID": "3", "minlengthField": " "},
"invalidValue": " "
},
{
"errorType": "less_than_min_length",
"tableName": "sites",
"columnName": "minlengthField",
"validationRuleFields": [],
"message": "less_than_min_length rule violated in table sites, column minlengthField, row(s) 4: Value \"NA\" (of length 2) is less than the min length of \"5\"",
"rowNumber": 4,
"row": {"siteID": "4", "minlengthField": "NA"},
"invalidValue": "NA"
},
{
"errorType": "less_than_min_length",
"tableName": "sites",
"columnName": "minlengthField",
"validationRuleFields": [],
"message": "less_than_min_length rule violated in table sites, column minlengthField, row(s) 5: Value \"x\" (of length 1) is less than the min length of \"5\"",
"rowNumber" : 5,
"row": {"siteID": "5", "minlengthField": "x"},
"invalidValue": "x"
}
]
}
16 changes: 16 additions & 0 deletions assets/validation-rules/empty/schema-v2-allowed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
schemaVersion: 2.0.0
schema:
sites:
type: list
schema:
type: dict
schema:
allowedField:
anyof:
- allowed:
- a
- b
empty: true
emptyTrimmed: false
forbidden:
- NA
14 changes: 14 additions & 0 deletions assets/validation-rules/empty/schema-v2-minlength.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schemaVersion: 2.0.0
schema:
sites:
type: list
schema:
type: dict
schema:
minlengthField:
anyof:
- minlength: 5
empty: true
emptyTrimmed: false
forbidden:
- NA
28 changes: 17 additions & 11 deletions assets/validation-rules/invalid-category/schema-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ schema:
type: dict
schema:
Collection:
allowed:
- Comp3h
- Comp8h
- FlowPr
- FlowRatePr
- other
anyof:
- allowed:
- Comp3h
- Comp8h
- FlowPr
- FlowRatePr
- other
empty: true
meta:
- ruleID: invalid_category
meta:
Expand Down Expand Up @@ -47,11 +49,13 @@ schema:
type: dict
schema:
type:
allowed:
anyof:
- allowed:
- other
- someOldCat1
- wwtpMuC
- wwtpMuS
empty: true
meta:
- ruleID: invalid_category
meta:
Expand Down Expand Up @@ -86,10 +90,12 @@ schema:
type: dict
schema:
type:
allowed:
- other
- wqCOD
- wwCOD
anyof:
- allowed:
- other
- wqCOD
- wwCOD
empty: true
meta:
- ruleID: invalid_category
meta:
Expand Down
10 changes: 6 additions & 4 deletions assets/validation-rules/invalid-category/schema-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ schema:
type: dict
schema:
coll:
allowed:
- comp3h
- comp8h
- flowPr
anyof:
- allowed:
- comp3h
- comp8h
- flowPr
empty: True
meta:
- ruleID: invalid_category
meta:
Expand Down
3 changes: 2 additions & 1 deletion assets/validation-rules/invalid-category/valid-dataset-2.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coll
NA
""

""
4 changes: 3 additions & 1 deletion assets/validation-rules/less-than-min-length/schema-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ schema:
type: dict
schema:
phoneNumber:
minlength: 10
anyof:
- empty: True
minlength: 10
meta:
- ruleID: less_than_min_length
meta:
Expand Down
4 changes: 3 additions & 1 deletion assets/validation-rules/less-than-min-length/schema-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ schema:
type: dict
schema:
phone:
minlength: 10
anyof:
- empty: True
minlength: 10
meta:
- ruleID: less_than_min_length
meta:
Expand Down
Loading
Loading