Validation: Respect\Validation\Exceptions\ComponentException: "with" is not a valid rule name
Hello,
Today I updated Respect/Validation up to master version and got error:
Respect\Validation\Exceptions\ComponentException: “with” is not a valid rule name
/app/backend/vendor/respect/validation/library/Factory.php:144 /app/backend/vendor/respect/validation/library/Validator.php:220 /app/backend/vendor/respect/validation/library/Validator.php:208 /app/backend/src/Domain/Genus/DTO/UpsertGenusCommandDTO.php:35
My code is below. Can you suggest me how to rewrite my code. I’m asking because in docs I can still find example with v:with.
Thanks.
{
/**
* @var string
*/
public $id;
/**
* @var array
*/
public $name;
/**
* @var string
*/
public $isoCode;
/**
* @var string
*/
public $phoneCode;
/**
* @var string
*/
public $timezone;
/**
* @var string
*/
public $controlKey;
/**
* @return array
*/
public function rules(): array
{
v::with('App\\Domain\\Country\\Validator\\CountryName');
v::with('App\\Domain\\Country\\Validator\\CountryTimezone');
v::with('App\\Domain\\Country\\Validator\\CountryIsoCode');
v::with('App\\Domain\\Country\\Validator\\CountryPhoneCode');
return [
'name.en' => v::CountryName($this->container, 'en', $this->id)->setName('name'),
'name.es' => v::optional(v::CountryName($this->container, 'es', $this->id))->setName('name'),
'name.ru' => v::optional(v::CountryName($this->container, 'ru', $this->id))->setName('name'),
'isoCode' => v::CountryIsoCode($this->container, $this->id)->setName('isoCode'),
'phoneCode' => v::CountryPhoneCode($this->container, $this->id)->setName('phoneCode'),
'timezone' => v::optional(v::CountryTimezone($this->container, $this->isoCode))->setName('timezone'),
];
}
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 17 (7 by maintainers)
@henriquemoody ok. thank you. I’ll try again 😃
Thank you. I’ll try 😃
Hey, @akorz!
I would suggest you to not use the master version for now because the API will still change. At this very moment you could do the same following this: https://github.com/Respect/Validation/blob/master/docs/feature-guide.md#custom-rules
In your case it would be: