<?php

namespace App\Http\Requests;

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

class CreateAdminInput 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 [
      'nickname' => ['required', 'between:1,30'],
      'account' => ['required', 'between:1,50'],
      'password' => ['required', 'between:6,20'],
    ];
  }

  public function messages()
  {
    return [
      'nickname.required' => 100005,
      'nickname.between' => 100006,
      'account.required' => 100015,
      'account.between' => 100016,
      'password.required' => 100007,
      'password.between' => 100008,
    ];
  }

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