diff --git a/stdnum/cn/ric.py b/stdnum/cn/ric.py index 12554b80..ed15cc80 100644 --- a/stdnum/cn/ric.py +++ b/stdnum/cn/ric.py @@ -65,7 +65,7 @@ def get_birth_place(number: str) -> dict[str, str]: number = compact(number) results = numdb.get('cn/loc').info(number[:6]) info = {k: v for part, props in results for k, v in props.items()} - if not info: + if 'county' not in info: raise InvalidComponent() year = get_birth_date(number).year # check if any found county was assigned at the birth year diff --git a/tests/test_cn_ric.doctest b/tests/test_cn_ric.doctest index ddd87802..d3ba9a4b 100644 --- a/tests/test_cn_ric.doctest +++ b/tests/test_cn_ric.doctest @@ -101,3 +101,9 @@ Invalid location: Traceback (most recent call last): ... InvalidComponent: ... +>>> ric.validate('361426199101010072') # known province, unknown county code +Traceback (most recent call last): + ... +InvalidComponent: ... +>>> ric.is_valid('361426199101010072') +False