I have 2 fields price and currency.I want to make dependency validation if price!=null currency field is required and if currency!=null price field is required as well as I want to check price field is numeric. if both field is null and that both field is not required.I want to validate in laravel 5.3
$this->validate($request,[
'price'=>'numeric',
'price'=>'required_if:currency,nullable',
'currency'=>'required_if:price,not nullable',
]);
The Validation Rule contains ISNULL(TEXT(Picklist_Field__c)). ISNULL determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE.
Field validation is an automated process of ascertaining that each field contains the correct value before the form is accepted. The concept is straightforward.
You can use required_with
for this.
$this->validate($request,[
'price'=>'required_with:currency|numeric',
'currency'=>'required_with:price',
]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With