![]() |
Error when validating credit card with multiple parameters in valid_cc_number rule - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: Error when validating credit card with multiple parameters in valid_cc_number rule (/showthread.php?tid=79357) |
Error when validating credit card with multiple parameters in valid_cc_number rule - funcion - 06-03-2021 I am using the codeigniter valid_cc_number credit card validation rule following the documentation https://codeigniter.com/user_guide/libraries/validation.html#available-rules It works when I add a card type: valid_cc_number[visa] PHP Code: $validation = \Config\Services::validation(); If I specify more than one card type like this: valid_cc_number[visa,mastercard] PHP Code: $validation = \Config\Services::validation(); Quote:It shows me the following message: Validation.valid_cc_number How can I validate the credit card number specifying more than one type of card as in the valid_cc_number rule? Credit card types: amex, unionpay, carteblanche, dinersclub, discover, interpayment, jcb, maestro, dankort, mir, troy, mastercard, visa, uatp, verve, cibc, rbc, tdtrust, scotia, bmoabm, hsbc Sample credit card numbers: https://www.paypalobjects.com/en_AU/vhelp/paypalmanager_help/credit_card_numbers.htm American Express: 378282246310005 Diners Club: 30569309025904 MasterCard: 5555555555554444 Visa: 4111111111111111 RE: Error when validating credit card with multiple parameters in valid_cc_number rule - paliz - 06-03-2021 Create custom validation library for validate cards It s better Go to app/validation. Php See the libraries create one call in vlidation cong Its the best way RE: Error when validating credit card with multiple parameters in valid_cc_number rule - InsiteFX - 06-04-2021 Have the user select the card type then on form submit button add it to the rule set. PHP Code: $validation->setRules(['card_number' => "required|valid_cc_number[$cardType]"]); Then check your validation. RE: Error when validating credit card with multiple parameters in valid_cc_number rule - includebeer - 06-05-2021 @InsiteFX Great and simple solution! But change the single quotes to double quotes to get the value of $cardType... ![]() PHP Code: $validation->setRules(['card_number' => "required|valid_cc_number[$cardType]"]); RE: Error when validating credit card with multiple parameters in valid_cc_number rule - eleumas - 05-17-2024 Hi! i have the same issue...but this solution is not good for user experience. How can I solve? RE: Error when validating credit card with multiple parameters in valid_cc_number rule - kenjis - 05-17-2024 This code is dangerous. Be sure to validate the value of $cardType before running the card_number validation. PHP Code: $validation->setRules(['card_number' => "required|valid_cc_number[$cardType]"]); |