Skip to content

[Q] - Whitespace as the separator – acceptable? #41

@olssonm

Description

@olssonm

Howdy! Writing some tests for a PHP-package I'm maintaining olssonm/swedish-entity that's built upon personnummer/php and I've encountered an oddity.

A whitespace as the separator seems to be accepted at the moment; i.e. 600411 8177 (or even with a tab instead of space) is returned as valid. This seems to be from the regex that's being used (I've only checked the PHP and JS-packages);

$reg = '/^(?\'century\'\d{2}){0,1}(?\'year\'\d{2})(?\'month\'\d{2})(?\'day\'\d{2})(?\'sep\'[\+\-\s]?)(?\'num\'(?!000)\d{3})(?\'check\'\d)$/';

There the separator, (?\'sep\'[\+\-\s]?), accepts +,- or whitespace.

The thing is though; I can't find any references that a whitespace should be valid for use in a personnummer or what the meaning would be.

Is this intended behaviour, or am I missing something? 🙃

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions