This PR moves the rules and validationAttributes into the Field class. This allows for better control of the validation of a field.
I came across this issue when working on a field model for the Grid fieldtype that deals with an array of data. The current implementation didn't allow for this scenario. Now you can simply override the default rules and validationAttributes methods if needed.
public function rules(): array
{
return [
"{$this->key}" => 'required|array',
"{$this->key}.*.issue" => 'required|string',
"{$this->key}.*.amount" => 'required|integer|min:1',
];
}
public function validationAttributes(): array
{
return [
"{$this->key}" => 'Ausgaben',
"{$this->key}.*.issue" => 'Ausgabe',
"{$this->key}.*.amount" => 'Anzahl',
];
}
This PR moves the
rules
andvalidationAttributes
into theField
class. This allows for better control of the validation of a field.I came across this issue when working on a field model for the Grid fieldtype that deals with an array of data. The current implementation didn't allow for this scenario. Now you can simply override the default
rules
andvalidationAttributes
methods if needed.