I want to customize a message for a string type, but I am only able to customize the message if its a number. Following is my code:
['mobile', 'string', 'min'=>10, 'message'=> 'Phone number must contain 10 digits. Please include area code.']
I want to allow for parenthesis and dashes as this is how I show it in the input field, but I strip it before validating and saving. It works if I put ‘number’ instead of ‘string’, but then the validation does not allow parenthesis and dashes. How do I add a custom message for a string type? The code does not show the custom message, but rather the default one. When replacing string with number in the code above, the custom message shows.
This is meant for Yii 2.0. Would someone please move this topic to the proper section.