mardi 30 octobre 2018

Laravel Validation: Unique + RegEx

I'm trying to validate a form where a WhatsApp number should be unique regardless of spaces/hyphens/dots and whatnot so that when a record is +1 234 567 8901, entries such as +1-234-567-8901 or +1-234-567-8901 or +1.234.567.8901 should be invalid:

'custom' => [
    'attribute-name'    => [
        'rule-name' => 'custom-message',
    ],

    'whatsapp'          => [
        'unique'    =>  'WhatsApp number is already in use'
    ],
],

But what I get is Laravel's built-in validation message which is:

'regex'                => 'The :attribute format is invalid',



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire