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

Dev #3

Merged
merged 2 commits into from Dec 7, 2017
Jump to file or symbol
Failed to load files and symbols.
+23 −0
Diff settings

Always

Just for now

Next

add validation on year filter

  • Loading branch information...
BohdanKaminskyi committed Dec 5, 2017
commit febab6e175b3ea7aa3e9d5765acf025dbc26ae51
View
@@ -35,3 +35,26 @@ def validate_data(car):
errors['owners_name'] = "This field is required."
return errors if errors else None
def validate_year_filter(start_year, end_year):
errors = {}
if start_year:
try:
st_year = int(start_year)
if st_year > 2017:
errors['from'] = "Value must be lower than 2018 and higher than 1940."
except:
errors['from'] = "Must be a positive integer."
else:
errors['from'] = "This field is required"
if start_year:
try:
e_year = int(end_year)
if e_year > 2017:
errors['to'] = "Value must be lower than 2018 and higher than 1940."
except:
errors['to'] = "Must be a positive integer."
else:
errors['to'] = "This field is required"
ProTip! Use n and p to navigate between commits in a pull request.