mardi 21 juillet 2020

How to add the trim function to validation rules in Laravel Request?

I have a validation rule as shown below. I am using exists to ensure that the contract is unique. The issue now is that contract numbers are stored with spaces in the database so this validation is not working for those cases (for example it will say the contract number does not exist which is due to the space before the number). To solve this, I want to do trim(contract_number). Please how can I apply the trim function to the contract_number below?

public function rules()
{
    return [   
        'tel' => 'required|max:25',
        'contract' => 'required|digits:9|exists:accounts,contract_number',
        'nom' => 'required|max:255',
        'language' => 'required|max:2',
        'g-recaptcha-response' => 'required|captcha',
    ];
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire