Mage2\Page\Requests\PageRequest::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['title'] = 'required|max:255';
        $validationRule['content'] = 'required';
        if ($this->getMethod() == 'POST') {
            $validationRule['slug'] = 'required|max:255|alpha_dash|unique:pages';
        }
        if ($this->getMethod() == 'PUT') {
            $validationRule['slug'] = 'required|max:255|alpha_dash';
        }
        return $validationRule;
    }