<?php

namespace App\Core\Validator;

use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Translation\Translator;
use Illuminate\Http\Request;

use App\Core\Validator\BaseValidator;

use Exception;

class ExampleValidator extends BaseValidator
{


    public function __construct
    (

        Translator $translator,
        Container $container,
        Request $request
    )
    {
        parent::__construct($translator, $container, $request);

    }

    public function rules($params = null)
    {
        return
            [
                'name' => 'required|min:32',
                'array1' => 'required|array|in:d,e,f',
                'phone' => 'required',
                'contact.address' => 'required',
                'contact.email' => 'required|email',
                'id' => 'required|integer'
            ];
    }


    public function messages()
    {

        // use example 'validation.input' =>  __('validation_type', ['input' => __('input language_key')]),
        // validation types in baseValidator switch-case block
        //

        $thisMessages = [
            'contact.email.required' =>  __('error-input-required', ['input' => __('myweb-contact-mail_title')]),
            'name.required' =>  __('error-input-required', ['input' => __('input-property_name')]),
            'name.min' =>  __('error-input-min', ['input' => __('input-property_name')]),

        ];

        return array_merge(parent::messages() , $thisMessages);
    }


    public function validate(array $params, array $rules = [], array $messages = [], array $customAttributes = [])
    {
        return $this->make($params, $this->rules($params), $this->messages());
    }

}
