Fakultas Ilmu Komputer UI

Commit 9d429081 authored by Kemas Khaidar Ali's avatar Kemas Khaidar Ali
Browse files

refactor fungsi validator

parent 4d44b5da
Pipeline #26508 passed with stages
in 5 minutes and 29 seconds
......@@ -108,11 +108,15 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
return name
def salary_validator(self, salary):
if not isinstance(salary, int):
raise ValidationError("Salary must number only")
raise ValidationError("Salary must number only")
def amount_validator(self, amount):
if not isinstance(amount, int):
raise ValidationError("Amount must number only")
def responsibilities_validator(self, responsibilities):
......@@ -142,12 +146,12 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
"open_time": raw_data['open_time'],
"close_time": raw_data['close_time'],
"name": raw_data['name'],
"salary": int(raw_data.get('salary', 0)),
"salary": raw_data.get('salary', 0),
"tag": raw_data.get('tag', ''),
"requirements": raw_data.get('requirements', ''),
"responsibilities": raw_data.get('responsibilities', ''),
"benefits": raw_data.get('benefits', ''),
"amount": int(raw_data.get('amount', 0)),
"amount": raw_data.get('amount', 0),
"recruiter_activity": raw_data.get('recruiter_activity', ''),
"description": raw_data['description'],
"working_period": raw_data['working_period'],
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment