I have this validation:
'target' => ['required', Rule::in(['ads', 'users',...])],
'expires_at' => 'required_if:target,!=,ads',
I need to make expires_at
is not required if the target
is ads
if the user chooses other options make expires_at
required again!
My Answer:
'required_if:source,website'
This validation rule states that the 'target' field is required if the 'source' field is equal to 'website'. If the 'source' field is not equal to 'website', then the 'target' field is not required.
Rate this post
4 of 5 based on 9761 votesComments