Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 964 Bytes

validate-input.md

File metadata and controls

43 lines (35 loc) · 964 Bytes

Validate user input

You can validate user input by using these custom rules

Example of implementation

<?php

namespace App\Http\Requests;

use Tarre\Laravel46Elks\Rules\E164NumberRule;
use Illuminate\Foundation\Http\FormRequest;

class StoreUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => ['required'],
            'phone_number' => ['required', new E164NumberRule],
        ];
    }
}