-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (31 loc) · 789 Bytes
/
main.py
File metadata and controls
34 lines (31 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from DataValidator import DataValidator
data = {
"title": 121,
"author": {
"name": "Maher",
"dob": "11/01/1996",
"email": "maher@birzeit.edu",
"friends": ["Chandler", "Monica", "Joey"],
},
"pages": 50,
"creation_date": "15-12-2015"
}
rules = {
"pages": "number|min:20|max:30",
"title": "string",
"creation_date": "date",
'author.friends': 'array',
'author.dob': 'date',
'author.haha': 'required'
}
customAttribute = {
'title': 'New Title',
'author.dob': 'Date of birth'
}
customErrorMessages = {
'pages.max': 'You shouldn\'t exceed 30 for pages'
}
x = DataValidator(data, rules, customAttribute, customErrorMessages)
print(x.getErrorMessages())
print(x.isValidData())
print(x.getFaildAttributes())