Skip to content

Commit

Permalink
Merge pull request #24 from ProzorroUKR/mnn_336
Browse files Browse the repository at this point in the history
Mnn 336 (added classification.id validator)
  • Loading branch information
dimka2014 committed Feb 21, 2019
2 parents f40b2a5 + 3c1f0e0 commit 1aa9b5e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/openprocurement/api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,16 @@ def validate_items_uniq(items, *args):
def validate_cpv_group(items, *args):
if items and len(set([i.classification.id[:3] for i in items])) != 1:
raise ValidationError(u"CPV group of items be identical")


def validate_classification_id(items, *args):
for item in items:
if item.classification.id.startswith('336'):
schemes = [x.scheme for x in item.additionalClassifications]
if item.classification.id == '33600000-6':
if schemes.count('INN') != 1:
raise ValidationError(u"Item with classification.id=33600000-6 have to contain exactly one \
additionalClassifications with scheme=INN")
if schemes.count('INN') > 1:
raise ValidationError(u"Item wich classification.id starts with 336 and contains \
additionalClassification objects have to contain no more than one additionalClassifications with scheme=INN")

0 comments on commit 1aa9b5e

Please sign in to comment.