Skip to content

Commit

Permalink
fix: handelled invalid price value in paid tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
codedsun committed Nov 18, 2019
1 parent 006110f commit ff7b233
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/api/schema/tickets.py
Expand Up @@ -67,6 +67,12 @@ def validate_quantity(self, data):
raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},
"quantity should be greater than or equal to max-order")

@validates_schema
def validate_price(self, data):
if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0):
raise UnprocessableEntity({'pointer': 'data/attributes/price'},
"paid ticket price should be valid")

@validates_schema(pass_original=True)
def validate_discount_code(self, data, original_data):
if 'relationships' in original_data and 'discount-codes' in original_data['data']['relationships']:
Expand Down

0 comments on commit ff7b233

Please sign in to comment.