Mage2\Catalog\Requests\CategoryRequest::rules PHP Method

rules() public method

Get the validation rules that apply to the request.
public rules ( ) : array
return array
    public function rules()
    {
        $validationRule = [];
        $validationRule['name'] = 'required|max:255';
        if ($this->getMethod() == 'POST') {
            $validationRule['slug'] = 'required|max:255|alpha_dash|unique:categories';
        }
        if ($this->getMethod() == 'PUT') {
            $validationRule['slug'] = 'required|max:255|alpha_dash';
        }
        return $validationRule;
    }
CategoryRequest