31783 - Add Canadian Postal Code Validation#4145
Conversation
| ) | ||
|
|
||
| CANADIAN_POSTAL_CODE_REGEX = re.compile( | ||
| r"^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z]\s?\d[ABCEGHJ-NPRSTV-Z]\d$", |
There was a problem hiding this comment.
FE Canadian Postal Code Regex Reference: https://github.com/bcgov/bcrs-shared-components/blob/8a9b95b9132d1dc9e1cd9e8fda1d915692fd165e/src/validators/is-valid-postal-code.ts#L5
There was a problem hiding this comment.
so postal codes with a tab or newline would pass validation. e.g. V6B\t1A1 or V6B\n1A1
think we want to block these?
|
|
|
||
|
|
||
|
|
||
| @pytest.mark.parametrize('filing_type, filing_data, office_type', [ |
There was a problem hiding this comment.
cool, didn't know you could stack parameters like this!
| actual_errors = [e['error'] for e in err.msg] | ||
| assert any(expected_error['error'] in actual_errors for expected_error in expected_msg) |
There was a problem hiding this comment.
are you able to keep the original test structure and maybe update the expected error message lists for postal code related tests? Otherwise it feels like some tests that are actually failing might fall through.



Issue #: /bcgov/entity#31783
Description of changes:
_validate_postal_codemethod to validate Canadian postal code format (ex: A1A 1A1)Ex:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the lear license (Apache 2.0).