-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation.py
65 lines (59 loc) · 1.71 KB
/
validation.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from models import Experience, Education, Skill
def validate_experience(json_data: dict):
'''
Validates the experience
'''
if 'spell_check' in json_data:
del json_data['spell_check']
try:
return Experience(**json_data)
except Exception as e:
raise ValueError(f"Invalid experience format: {e}")
def validate_education(json_data: dict):
'''
Validates the education
'''
if 'spell_check' in json_data:
del json_data['spell_check']
try:
return Education(**json_data)
except Exception as e:
raise ValueError(f"Invalid education format: {e}")
def validate_skill(json_data: dict):
'''
Validates the skill
'''
if 'spell_check' in json_data:
del json_data['spell_check']
try:
return Skill(**json_data)
except Exception as e:
raise ValueError(f"Invalid skill format: {e}")
data = {
"experience": {
"title": "Software Developer",
"company": "A Cooler Company",
"start_date": "October 2022",
"end_date": "Present",
"description": "Writing JavaScript Code",
"logo": "example-logo.png",
"spell_check": True
},
"education": {
"course": "Engineering",
"school": "NYU",
"start_date": "October 2022",
"end_date": "August 2024",
"grade": "86%",
"logo": "example-logo.png",
"description": "I was head of the debate team at university"
},
"skill": {
"name": "JavaScript",
"proficiency": "2-4 years",
"logo": "example-logo.png"
}
}
print(validate_experience(data['experience']))
print(validate_education(data['education']))
print(validate_skill(data['skill']))