Skip to content

Invalid phone string parsing is not throwing exception or seting number state to invalid #23

Description

@Badabum

I've tried to use this lib, but faced some weird (as for me) behavior. I have string with wrong telephone number +38093sdaf342, 380 is a code of Ukraine, but any non-digit characters is not allowed in Ukrainian numbers. Here is the function where I try to validate this number.

public bool IsValidPhoneNumber(string number,string regionCode)
        {
            var utils = PhoneNumberUtil.GetInstance();
            var phoneNumberInstance = utils.Parse(number,regionCode);
            return utils.IsValidNumber(phoneNumberInstance);
       }

Passed params to function number=+38093sdaf342, regionCode="UA".
Ive seen that in created byParsefunction object propertyNationalNumber` is set to 937323342. Why is it so? I thought that this number must be validated as invalid cause it contains not only digits. Is it a bug or an expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions