diff --git a/.gitignore b/.gitignore index 7c4b9e95..800185f8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ composer.lock .phpunit.result.cache phpunit.xml coverage +.phpunit.cache diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results index ec8f7adc..c217eb96 100644 --- a/.phpunit.cache/test-results +++ b/.phpunit.cache/test-results @@ -1 +1 @@ -{"version":1,"defects":{"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct_with_different_default_character":8},"times":{"Milwad\\LaravelValidate\\Tests\\BaseTest::success":0.037,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::all_lang_folders_publish_successfully":0.35,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::config_file_publish_successful":0.148,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::base64_is_valid":0.014,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::base64_is_not_valid":0.003,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::bitcoin_address_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::bitcoin_address_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::camel_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::camel_case_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::capital_char_with_number_is_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::capital_char_with_number_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::car_number_is_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::car_number_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCartNumberIranTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCartNumberIranTest::cart_number_iran_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::credit_card_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::credit_card_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::discord_username_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::discord_username_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::domain_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::domain_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::duplicate_characters_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::duplicate_characters_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_number_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_number_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_string_is_valid":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_string_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::check_number_is_even":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::check_number_is_not_even":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::text_has_hashtag":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::text_has_no_hashtag":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::text_is_valid_hex_code":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::text_is_not_valid_hex_code":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::html_tag_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::html_tag_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_without_country":0.008,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_with_a_country":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_with_multiple_countries":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_without_country":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_with_a_country":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_with_multiple_countries":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::imei_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::imei_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::ipv4_address_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::ipv4_address_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::ipv6_address_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::ipv6_address_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::postal_code_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::postal_code_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_correct":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_string":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct_with_different_default_character":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_correct_with_different_default_character":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::jwt_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::jwt_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::kebab_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::kebab_case_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::name_day_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::name_day_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::national_code_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::national_code_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::number_is_odd":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::number_is_not_odd":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::pascal_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::pascal_case_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::pattern_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::pattern_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::phone_number_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::phone_number_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::all_phone_number_is_valid_by_specific_code":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::if_phone_number_validate_method_is_not_exists":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::port_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::port_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::slash_end_of_string_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::slash_end_of_string_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::slug_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::slug_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::snake_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::snake_case_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::password_is_strong":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::password_is_not_strong":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::ulid_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::ulid_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::url_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::url_is_nor_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::username_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::username_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::uuid_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::uuid_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vatid_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vatid_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vat_is_to_long_valid":0.001}} \ No newline at end of file +{"version":1,"defects":{"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct_with_different_default_character":8,"Milwad\\LaravelValidate\\Tests\\BaseTest::success":8,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::success":8,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::all_lang_folders_publish_successfully":8,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::config_file_publish_successful":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::base64_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::base64_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::bitcoin_address_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::bitcoin_address_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::camel_case_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::camel_case_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::capital_char_with_number_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::capital_char_with_number_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::car_number_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::car_number_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCartNumberIranTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCartNumberIranTest::cart_number_iran_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::credit_card_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::credit_card_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::discord_username_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::discord_username_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::domain_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::domain_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::duplicate_characters_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::duplicate_characters_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_number_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_number_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_string_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_string_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::check_number_is_even":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::check_number_is_not_even":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::text_has_hashtag":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::text_has_no_hashtag":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::text_is_valid_hex_code":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::text_is_not_valid_hex_code":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::html_tag_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::html_tag_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_without_country":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_with_a_country":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_with_multiple_countries":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_without_country":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_with_a_country":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_with_multiple_countries":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::imei_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::imei_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::ipv4_address_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::ipv4_address_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::ipv6_address_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::ipv6_address_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::postal_code_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::postal_code_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_correct":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_string":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_correct_with_different_default_character":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::jwt_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::jwt_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::kebab_case_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::kebab_case_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::name_day_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::name_day_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::national_code_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::national_code_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::number_is_odd":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::number_is_not_odd":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::pascal_case_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::pascal_case_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::pattern_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::pattern_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::phone_number_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::phone_number_is_not_valid":7,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::all_phone_number_is_valid_by_specific_code":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::if_phone_number_validate_method_is_not_exists":7,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::port_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::port_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::slash_end_of_string_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::slash_end_of_string_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::slug_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::slug_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::snake_case_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::snake_case_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::password_is_strong":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::password_is_not_strong":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::ulid_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::ulid_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::url_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::url_is_nor_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::username_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::username_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::uuid_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::uuid_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::success":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vatid_is_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vatid_is_not_valid":8,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vat_is_to_long_valid":8},"times":{"Milwad\\LaravelValidate\\Tests\\BaseTest::success":0.037,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::all_lang_folders_publish_successfully":0.35,"Milwad\\LaravelValidate\\Tests\\LaravelValidateServiceProviderTest::config_file_publish_successful":0.148,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::base64_is_valid":0.014,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBase64Test::base64_is_not_valid":0.003,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::bitcoin_address_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidBitcoinAddressTest::bitcoin_address_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::camel_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCamelCaseTest::camel_case_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::capital_char_with_number_is_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCapitalCharWithNumberTest::capital_char_with_number_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::car_number_is_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCarNumberTest::car_number_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCartNumberIranTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCartNumberIranTest::cart_number_iran_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::credit_card_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidCreditCardTest::credit_card_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::discord_username_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDiscordUsernameTest::discord_username_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::domain_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDomainTest::domain_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::success":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::duplicate_characters_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateCharacterTest::duplicate_characters_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_number_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_number_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_string_is_valid":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidDuplicateTest::duplicate_string_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::check_number_is_even":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidEvenNumberTest::check_number_is_not_even":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::text_has_hashtag":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHashtagTest::text_has_no_hashtag":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::text_is_valid_hex_code":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHexColorTest::text_is_not_valid_hex_code":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::html_tag_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidHtmlTagTest::html_tag_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_without_country":0.008,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_with_a_country":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_valid_with_multiple_countries":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_without_country":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_with_a_country":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIbanTest::iban_is_not_valid_with_multiple_countries":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::imei_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidImeiTest::imei_is_not_valid":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::ipv4_address_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV4Test::ipv4_address_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::ipv6_address_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIpAddressIPV6Test::ipv6_address_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::postal_code_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidIranPostalCodeTest::postal_code_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_correct":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_string":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_correct_with_different_default_character":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJalaliDateTest::jalali_date_is_not_correct_with_different_default_character":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::jwt_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidJwtTest::jwt_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::kebab_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidKebabCaseTest::kebab_case_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::name_day_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNameDaysWeekTest::name_day_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::national_code_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidNationalCardTest::national_code_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::number_is_odd":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidOddNumberTest::number_is_not_odd":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::pascal_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPascalCaseTest::pascal_case_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::pattern_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPatternTest::pattern_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::success":0.106,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::phone_number_is_valid":0.023,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::phone_number_is_not_valid":0.003,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::all_phone_number_is_valid_by_specific_code":0.002,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPhoneNumberTest::if_phone_number_validate_method_is_not_exists":0.014,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::port_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidPortTest::port_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::slash_end_of_string_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlashEndOfStringTest::slash_end_of_string_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::slug_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSlugTest::slug_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::snake_case_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidSnakeCaseTest::snake_case_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::password_is_strong":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidStrongPasswordTest::password_is_not_strong":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::ulid_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUlidTest::ulid_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::url_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUrlTest::url_is_nor_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::username_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUsernameTest::username_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::uuid_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidUuidTest::uuid_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::success":0,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vatid_is_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vatid_is_not_valid":0.001,"Milwad\\LaravelValidate\\Tests\\Rules\\ValidVatIdTest::vat_is_to_long_valid":0.001}} \ No newline at end of file diff --git a/config/laravel-validate.php b/config/laravel-validate.php index 286de027..a3b6e80e 100644 --- a/config/laravel-validate.php +++ b/config/laravel-validate.php @@ -1,12 +1,41 @@ [ - 'base-64' => [ - 'name' => 'base64', - 'class' => ValidBase64::class, - ], + 'phone-country' => [ + 'DE' => DEPhoneValidator::class, + 'EN' => ENPhoneValidator::class, + 'ES' => ESPhoneValidator::class, + 'FR' => FRPhoneValidator::class, + 'GR' => GRPhoneValidator::class, + 'ID' => IDPhoneValidator::class, + 'IN' => INPhoneValidator::class, + 'IR' => IRPhoneValidator::class, + 'IT' => ITPhoneValidator::class, + 'JA' => JAPhoneValidator::class, + 'KO' => KOPhoneValidator::class, + 'NE' => NEPhoneValidator::class, + 'RU' => RUPhoneValidator::class, + 'SA' => SAPhoneValidator::class, + 'SE' => SEPhoneValidator::class, + 'TR' => TRPhoneValidator::class, + 'ZH' => ZHPhoneValidator::class, ], ]; diff --git a/src/LaravelValidateServiceProvider.php b/src/LaravelValidateServiceProvider.php index f61aad6e..ac557350 100644 --- a/src/LaravelValidateServiceProvider.php +++ b/src/LaravelValidateServiceProvider.php @@ -3,6 +3,7 @@ namespace Milwad\LaravelValidate; use Illuminate\Support\ServiceProvider; +use Milwad\LaravelValidate\Utils\CountryPhoneCallback; class LaravelValidateServiceProvider extends ServiceProvider { @@ -73,4 +74,18 @@ private function publishConfigFile(): void __DIR__.'/../config/laravel-validate.php' => config_path('laravel-validate.php'), ], 'laravel-validate-config'); } + + /** + * Boot applications. + * + * @throws \Throwable + */ + public function boot(): void + { + $countries = config('laravel-validate.phone-country', []); + + foreach ($countries as $code => $country) { + CountryPhoneCallback::addValidator($code, $country); + } + } } diff --git a/src/Rules/ValidPhoneNumber.php b/src/Rules/ValidPhoneNumber.php index 5732ec92..3df2a854 100644 --- a/src/Rules/ValidPhoneNumber.php +++ b/src/Rules/ValidPhoneNumber.php @@ -17,7 +17,7 @@ public function __construct(protected ?string $code = null) public function passes($attribute, $value): bool { if (is_string($this->code)) { - $passes = (new CountryPhoneCallback($value, $this->code))->callPhoneValidator(); + $passes = CountryPhoneCallback::callPhoneValidator($this->code, $value); return collect($passes)->some(fn ($passe) => $passe); } diff --git a/src/Utils/Country.php b/src/Utils/Country.php index f2ac9767..6539bef2 100644 --- a/src/Utils/Country.php +++ b/src/Utils/Country.php @@ -42,7 +42,7 @@ class Country public const CHAD = 'TD'; - public const CHINA = 'zh'; + public const CHINA = 'ZH'; public const COMOROS = 'KM'; diff --git a/src/Utils/CountryPhoneCallback.php b/src/Utils/CountryPhoneCallback.php index 8834e2e1..b73d152e 100644 --- a/src/Utils/CountryPhoneCallback.php +++ b/src/Utils/CountryPhoneCallback.php @@ -2,174 +2,39 @@ namespace Milwad\LaravelValidate\Utils; +use Milwad\LaravelValidate\Utils\CountryPhoneValidator\CountryPhoneValidator; +use RuntimeException; + class CountryPhoneCallback { /** - * Create a new phone validator instance. - */ - public function __construct(private mixed $value, private string $code, ?string $attribute = null) - { - } - - // TODO: Add a feature to add validate method for your own country! - - /** - * Validate Iran phone number. + * Country Validate classes. */ - protected function validateIR(): false|int - { - return preg_match('/^(\+98|0)?9\d{9}$/', $this->value); - } + protected static array $validators = []; /** - * Validate Iran phone number. - */ - protected function validateEN(): false|int - { - return preg_match('/^(?:\+44|0)7\d{9}$/', $this->value); - } - - /** - * Validate Nigeria phone number. - */ - protected function validateNE(): false|int - { - return preg_match('/^(\+227|00227|227)?\d{8}$/', $this->value); - } - - /** - * Validate Saudi Arabia phone number. - */ - protected function validateSA(): false|int - { - return preg_match('/^((\+966)|0)?5\d{8}$/', $this->value); - } - - /** - * Validate Germany phone number. - */ - protected function validateDE(): false|int - { - return preg_match('/^((\+49)|(0))(1|15|16|17|19|30|31|32|33|34|40|41|42|43|44|49|151|152|153|155|156|157|159|160|162|163|180|181|182|183|184|185|186|187|188|170|171|172|173|174|175|176|177|178|179)\d{7,8}$/', $this->value); - } - - /** - * Validate Greece phone number. - */ - protected function validateGR(): false|int - { - return preg_match('/^\+30[2-9]\d{2}\d{3}\d{4}$/', $this->value); - } - - /** - * Validate Spain phone number. - */ - protected function validateES(): false|int - { - return preg_match('/^(?:\+34|0034|34)?[6789]\d{8}$/', $this->value); - } - - /** - * Validate France phone number. - */ - protected function validateFR(): false|int - { - return preg_match('/^(?:\+33|0033|0)(?:[1-9](?:\d{2}){4}|[67]\d{8})$/', $this->value); - } - - /** - * Validate India phone number. - */ - protected function validateIN(): false|int - { - return preg_match('/^(?:(?:\+|0{0,2})91(\s|-)?)?[6789]\d{9}$/', $this->value); - } - - /** - * Validate Indonesia phone number. - */ - protected function validateID(): false|int - { - return preg_match('/^(?:\+62|0)(?:\d{2,3}\s?){1,2}\d{4,8}$/', $this->value); - } - - /** - * Validate Italy phone number. - */ - protected function validateIT(): false|int - { - return preg_match('/^\+39\d{8,10}$/', $this->value); - } - - /** - * Validate Japanese phone number. - */ - protected function validateJA(): false|int - { - return preg_match('/(\d{2,3})-?(\d{3,4})-?(\d{4})/', $this->value); - } - - /** - * Validate Korean phone number. - */ - protected function validateKO(): false|int - { - return preg_match('/^(?:\+82|0)(?:10|1[1-9])-?\d{3,4}-?\d{4}$/', $this->value); - } - - /** - * Validate Russian phone number. - */ - protected function validateRU(): false|int - { - return preg_match('/^(?:\+7|8)(?:\s?\(?\d{3}\)?\s?\d{3}(?:-?\d{2}){2}|\s?\d{2}(?:\s?\d{2}){3})$/', $this->value); - } - - /** - * Validate Sweden phone number. - */ - protected function validateSE(): false|int - { - return preg_match('/^(?:\+46|0) ?(?:[1-9]\d{1,2}-?\d{2}(?:\s?\d{2}){2}|7\d{2}-?\d{2}(?:\s?\d{2}){2})$/', $this->value); - } - - /** - * Validate Turkey phone number. + * Add new country validator. + * + * @throws \Throwable */ - protected function validateTR(): false|int + public static function addValidator(string $code, string $validator): void { - return preg_match('/^(?:\+90|0)(?:\s?[1-9]\d{2}\s?\d{3}\s?\d{2}\s?\d{2}|[1-9]\d{2}-?\d{3}-?\d{2}-?\d{2})$/', $this->value); - } + if (! new $validator instanceof CountryPhoneValidator) { + throw new RuntimeException('The validator is not instance of CountryPhoneValidator'); + } - /** - * Validate Chinese phone number. - */ - protected function validateZH(): false|int - { - return preg_match('/^(?:\+86)?1[3-9]\d{9}$/', $this->value); + self::$validators[$code] = $validator; } /** - * Call the phone validator method for each country code and return the results. - * - * @throws \BadMethodCallException if the validator method for a country code does not exist. + * Call country validate class. */ - public function callPhoneValidator(): array + public static function callPhoneValidator(string $code, $value) { - $results = []; - $codes = explode(',', $this->code); - $codes = array_map('strtoupper', $codes); - - foreach ($codes as $code) { - $methodName = 'validate'.$code; - - if (method_exists($this, $methodName)) { - $results[$code] = $this->{$methodName}(); - } else { - throw new \BadMethodCallException("Validator method '{$methodName}' does not exist."); - } + if (isset(self::$validators[$code])) { + return (new self::$validators[$code])->validate($value); + } else { + throw new \BadMethodCallException("Validator method for '$code' does not exist."); } - - return $results; } } diff --git a/src/Utils/CountryPhoneValidator/CountryPhoneValidator.php b/src/Utils/CountryPhoneValidator/CountryPhoneValidator.php new file mode 100644 index 00000000..6700da23 --- /dev/null +++ b/src/Utils/CountryPhoneValidator/CountryPhoneValidator.php @@ -0,0 +1,8 @@ + [new ValidPhoneNumber()], + 'phone_number' => [new ValidPhoneNumber], 'phone_bj' => [new ValidPhoneNumber(Country::IRAN)], ]; $data = [ @@ -120,7 +120,7 @@ public function all_phone_number_is_valid_by_specific_code() public function if_phone_number_validate_method_is_not_exists() { $this->expectException(BadMethodCallException::class); - $this->expectExceptionMessage("Validator method 'validateAZ' does not exist."); + $this->expectExceptionMessage("Validator method for 'AZ' does not exist."); $rules = ['phone' => [new ValidPhoneNumber(Country::AZERBAIJAN)]]; $data = ['phone' => '+62812345678'];