From 873282c158faa9bbd4716dab5280bf537543ce48 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 14 Aug 2015 11:06:26 +0300 Subject: Improved part number recognition --- gsxws/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gsxws/core.py b/gsxws/core.py index 55a086f..4fd4ee3 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -109,12 +109,16 @@ def validate(value, what=None): >>> validate('XD368Z/A', 'partNumber') True + >>> validate('XGWL2Z/A', 'partNumber') + True >>> validate('ZM661-5883', 'partNumber') True >>> validate('661-01234', 'partNumber') True >>> validate('B661-6909', 'partNumber') True + >>> validate('G143111400', 'dispatchId') + True >>> validate('blaa', 'serialNumber') False >>> validate('MacBook Pro (Retina, Mid 2012)', 'productName') @@ -126,12 +130,12 @@ def validate(value, what=None): raise ValueError('%s is not valid input (%s != string)' % (value, type(value))) rex = { - 'partNumber': r'^([A-Z]{1,2})?\d{3}\-?(\d{4,5}|[A-Z]{1,2})(/[A-Z])?$', + 'partNumber': r'^([A-Z]{1,4})?\d{1,3}\-?(\d{1,5}|[A-Z]{1,2})(/[A-Z])?$', 'serialNumber': r'^[A-Z0-9]{11,12}$', 'eeeCode': r'^[A-Z0-9]{3,4}$', 'returnOrder': r'^7\d{9}$', 'repairNumber': r'^\d{12}$', - 'dispatchId': r'^G\d{9}$', + 'dispatchId': r'^[A-Z]+\d{9,15}$', 'alternateDeviceId': r'^\d{15}$', 'diagnosticEventNumber': r'^\d{23}$', 'productName': r'^i?Mac', -- cgit v1.2.3