lundi 25 janvier 2016

Alter request object before validation

if($key == "postcode") {
    $this->validate($request, [
    'postcode' => ['required','regex:#^(GIR ?0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]([0-9ABEHMNPRV-Y])?)|[0-9][A-HJKPS-UW]) ?[0-9][ABD-HJLNP-UW-Z]{2})$#'],
    ]);
}

I need to convert the postcode field into uppercase before I pass it in to this validate function. I tried $request->input('postcode') = strtoupper($request->input('postcode')); but got;

Can't use method return value in write context.

I want to keep $request as the whole Request object ideally. Otherwise I’d just pass in the $request->input('postcode') on it's own. Actually I think the method is type-hinted for Request.

This is Laravel 5.1



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/23nuZ9P
via IFTTT

Aucun commentaire:

Enregistrer un commentaire