32910 Add Validation for Foreign Business Identifier Format and MRAS …#4419
Conversation
loneil
left a comment
There was a problem hiding this comment.
Change looks good, let's just add a unit test for _validate_foreign_identifier with parameterized data covering the examples in the PR description (that's a good list for coverage).
Can take a look in /home/loneil/development/registries/lear/legal-api/tests/unit/services/filings/validations/test_amalgamation_application.py
Can be just an atomic test importing _validate_foreign_identifier, running it against the params (take a look at other @pytest.mark.parametrize examples if needed) asserting the errors. Can search for test_validate_incorporation_party_names as an example of this pattern
…entifier_Format_and_MRAS_Requirement
|



#32910 : /bcgov/entity#32910
Description of changes:
For any foreign amalgamating business, the backend previously failed to validate the identifier. The frontend required an identifier when the foreign jurisdiction was MRAS — meaning country = CA and region in AB, MB, NS, ON, QC, SK — and enforced:
^[0-9a-zA-Z-]+$However, the backend only used the identifier for duplicate detection and did not validate format, length, or MRAS-based conditionality. As a result, invalid values could be saved.
The backend now mirrors the frontend rules:
^[0-9a-zA-Z-]+$Example:
POST to
/api/v2/businesses/<T-id>/filings?only_validate=true"identifier": "A1234567", "foreignJurisdiction": { "country": "CA", "region": "AB" }"identifier": "", "foreignJurisdiction": { "country": "CA", "region": "AB" }"identifier": "AB", "foreignJurisdiction": { "country": "CA", "region": "AB" }"identifier": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "foreignJurisdiction": { "country": "CA", "region": "AB" }"identifier": "SK#99001", "foreignJurisdiction": { "country": "CA", "region": "SK" }"identifier": "", "foreignJurisdiction": { "country": "CA", "region": "NB" }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).