Laravel: validate an integer field that needs to be greater than another

前端 未结 8 2226
情歌与酒
情歌与酒 2020-11-27 15:08

I have two fields that are optional only if both aren\'t present:

$rules = [
  \'initial_page\' => \'required_with:end_page|integer|min:1|digits_between:          


        
8条回答
  •  无人及你
    2020-11-27 15:50

    use gt = grater than :value|field

    use gte = grater than equal :value|field

    use lt = less than :value|field

    use lte = less than equal :value|field

    in your case it's

    gt:initial_page
    

    and the result will be

    $rules = array(
          'initial_page' => 'required_with:end_page|numeric|min:1|digits_between: 1,5',
          'end_page' => 'required_with:initial_page|numeric|gt:initial_page|min:2|digits_between:1,5'
          );
    

提交回复
热议问题