intl_phone_number_input icon indicating copy to clipboard operation
intl_phone_number_input copied to clipboard

validation error on Saudi Arabia number

Open AbdulAhad1192 opened this issue 3 years ago • 1 comments

Describe the bug It only accepts numbers starting with 11, but 11 is the landline area code for Riyadh and I want to include other landline area codes too

Package version intl_phone_number_input: ^0.7.0+2

Flutter version Flutter 2.5.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision ffb2ecea52 (3 weeks ago) • 2021-09-17 15:26:33 -0400 Engine • revision b3af521a05 Tools • Dart 2.14.2

To Reproduce Steps to reproduce the behavior:

  1.                                          Obx(
                       () {
                         return InternationalPhoneNumberInput(
                           selectorConfig: const SelectorConfig(
                             selectorType: PhoneInputSelectorType.DIALOG,
                             setSelectorButtonAsPrefixIcon: false,
                             leadingPadding: 10,
                             trailingSpace: false,
                           ),
                           initialValue: controller.phoneNo,
                           spaceBetweenSelectorAndTextField: 0,
                           maxLength: digit.value,
    
                           // key: controller.phonekey,
                           onInputChanged: (number) {
                             // controller.phonekey.currentState!.validate();
                             controller.phoneNo = number;
    
                             // if(number.toString().trim().contains("+966"))
                             //   {
                             //     digit.value = 11;
                             //   }
                             // else
                             //   {
                             //     digit.value = 12;
                             //   }
    
                             // print(controller.phoneNo);
                           },
                           // validator: (val) {
                           //   if(!controller.isValidPhone!.value)
                           //     {
                           //       return "Please provide valid number";
                           //     }
                           // },
                           errorMessage: "Please provide valid number",
                           inputDecoration: AppTheme.textFormFeildInputDecoration(
                             hintText: "1234567890",
                             labelText: "Phone Number",
                           ),
                           formatInput: true,
                           onInputValidated: (val) {
                             controller.isValidPhone!.value = val;
                             // print(controller.isValidPhone!.value);
    
                           },
                           countries: ["IN","SA"],
    
                         );
                       }
                     ),
    
  2. i want a phone feild with indian and saudi arabia numbers , the indian validation is working fine but it is not able to validate the saudi arabic numbers

  3. on input other than numbers starting with 11 it gives an error

  4. validation error

Expected behavior i want to validate SA numbers

Screenshots If applicable, add screenshots to help explain your problem.

** Targeted platforms (please complete the following information):** I have tested in Android OS

  • OS
  • Web [✔ or ❌]

Additional context Add any other context about the problem here.

AbdulAhad1192 avatar Oct 06 '21 12:10 AbdulAhad1192

I'm facing the same issue and since there's no fix yet, I've written my custom validator using validator: param.

emumair avatar Feb 22 '22 09:02 emumair