{"record":{"id":"0890647d04faad2a","repo":"ory/kratos","slug":"the-provided-number-is-not-a-valid-phone-number","errorCode":null,"errorMessage":"the provided number is not a valid phone number","messagePattern":"the provided number is not a valid phone number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"x/normalize.go","lineNumber":158,"sourceCode":"\t\t\treturn \"\", err\n\t\t}\n\t\temail, err := mail.ParseAddress(value)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn email.Address, nil\n\n\tcase \"sms\":\n\t\tvalue, err := applyPRECIS(phoneProfile, value, false)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tnumber, err := phonenumbers.Parse(value, \"\")\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif !phonenumbers.IsValidNumber(number) {\n\t\t\treturn \"\", errors.New(\"the provided number is not a valid phone number\")\n\t\t}\n\t\treturn phonenumbers.Format(number, phonenumbers.E164), nil\n\n\tcase \"username\":\n\t\tfallthrough\n\tdefault:\n\t\treturn applyPRECIS(emailProfile, value, true)\n\t}\n}\n","sourceCodeStart":140,"sourceCodeEnd":168,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/x/normalize.go#L140-L168","documentation":"NormalizeIdentifier parses a value with the phonenumbers library when the schema annotation requests phone normalization. If the parsed number is not a valid phone number for any region, it refuses to normalize and returns this error, because storing an invalid E.164 identifier would corrupt identity matching.","triggerScenarios":"Registering/submitting a trait whose identity schema uses the phone normalization annotation, with a string that parses but fails phonenumbers.IsValidNumber (wrong country code, impossible number, or a non-phone string like '12345').","commonSituations":"Users typing a national number without a country code that cannot be inferred; placeholders like '000-000-0000'; schemas defaulting to region '' so no default country applies; migration scripts importing junk phone values.","solutions":["Provide the number in full international E.164 format, e.g. +14155552671","Add a default country code in the identity schema's normalization options so national formats can be resolved","Validate the phone number client-side (format + plausible country) before submitting the flow","Fix imported/migrated data with a phone validation library before creating identities"],"exampleFix":"// before\n{\"traits\": {\"phone\": \"555-1234\"}}\n// after\n{\"traits\": {\"phone\": \"+14155551234\"}}","handlingStrategy":"validation","validationCode":"p, err := phonenumbers.Parse(value, defaultRegion); if err != nil || !phonenumbers.IsValidNumber(p) { /* reject before submit */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Collect phones in E.164 format from the UI","Set a default region in schema normalization options","Sanitize imported datasets with a phone validator","Reject obvious placeholders like 0000000000"],"tags":["go","validation","phone-number","e164"],"backgroundTag":"invalid-identifier-format","analyzedSha":"b86338da04a040247a07f46100a86dcfb3875909","analyzedAt":"2026-09-07T15:58:15.934Z","contentChangedAt":"2026-09-07T15:58:15.934Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}