<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Yo;

class EditAuthInput 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', 'between:1,20'],
      'title' => ['required', 'between:1,20'],
      'icon' => ['between:0,100'],
      'order' => ['min:0', 'max:999'],
    ];
  }

  public function messages()
  {
    return [
      'name.required' => 100019,
      'name.between' => 100020,
      'title.required' => 100011,
      'title.between' => 100012,
      'icon.between' => 100021,
      'order.min' => 100022,
      'order.max' => 100022,
    ];
  }

  public function failedValidation(Validator $validator)
  {
    Yo::error_echo($validator->errors()->first());
  }
}
