scribe icon indicating copy to clipboard operation
scribe copied to clipboard

feat: add support to 'sometimes' rule

Open max13fr opened this issue 10 months ago • 0 comments

Hello,

I added the support for the "sometimes" validator rule that allow to skip all following validators like "required".

Currently, a field with this following rules was consired as required (but it shouldn't) :

  • 'consent_cgu' => 'sometimes|accepted'
  • 'other_field' => 'sometimes|required|...' ("filled" rule seems better for this case but "filled_if", "filled_with", ... not existing so it's not an universal solution).

It notably fix this issue without any change to follow Laravel behaviour : https://github.com/knuckleswtf/scribe/issues/343

As Laravel behaviour, the following rules is correctly returned as required : 'badrule'=> 'required|sometimes|...'

Best regard

max13fr avatar Feb 25 '25 14:02 max13fr