diff options
author | Filipp Lepalaan <f@230.to> | 2013-08-16 16:01:09 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-08-16 16:01:09 +0300 |
commit | 70039c9cb3cb0b6c70ea1c7241451a3ea45a13d5 (patch) | |
tree | 41ec9eee0a84f372d9dfb9d414ba2c7c5824c542 /gsxws | |
parent | 01e2049cfaf98018654549d674fee3ce86cbdadc (diff) | |
download | py-gsxws-70039c9cb3cb0b6c70ea1c7241451a3ea45a13d5.tar.gz py-gsxws-70039c9cb3cb0b6c70ea1c7241451a3ea45a13d5.tar.bz2 py-gsxws-70039c9cb3cb0b6c70ea1c7241451a3ea45a13d5.zip |
Better partNumber detection
Diffstat (limited to 'gsxws')
-rw-r--r-- | gsxws/core.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gsxws/core.py b/gsxws/core.py index b49a5d6..0bf5308 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -100,6 +100,13 @@ def validate(value, what=None): """ Tries to guess the meaning of value or validate that value looks like what it's supposed to be. + + >>> validate('XD368Z/A', 'partNumber') + True + >>> validate('blaa', 'serialNumber') + False + >>> validate('MacBook Pro (Retina, Mid 2012)', 'productName') + True """ result = None @@ -107,7 +114,7 @@ def validate(value, what=None): raise ValueError('%s is not valid input') rex = { - 'partNumber': r'^([A-Z]{1,2})?\d{3}\-?(\d{4}|[A-Z]{2})(/[A-Z])?$', + 'partNumber': r'^([A-Z]{1,2})?\d{3}\-?(\d{4}|[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}$', |