KD2 FW

Form

Validation rules

The rules are mostly the same as the ones implemented in Laravel

  • required: The field must be present and not empty.
  • required_with:other_field,another_field: Only require that field if either other_field and another_field are not empty.
  • required_with_all:other_field,another_field: Only require that field if both other_field and another_field are not empty.
  • required_without:other_field,another_field: Only require that field if either other_field or another_field are empty.
  • required_without_all:other_field,another_field: Only require that field if other_field and another_field are empty.
  • required_if:other_field,value…: only require this field if other_field is equal to any value
  • required_unless:other_field,value…: only require this field unless other_field is equal to any value
  • absent: The field must not be present
  • file: Field must be a valid file uploaded.
  • active_url: Must be a URL and the host in the URL must have a valid DNS A record.
  • alpha: Must contain only letters.
  • alpha_dash: Must contain only letters or dash.
  • alpha_num: Must contains only letters or numbers
  • array: must be an array
  • between:x,y: must be a number and be between x and y
  • bool or boolean: must be evaluated as either true or false
  • color: must be an hexadecimal color, eg. aaff99
  • confirmed: another field named "field_confirmed" must be present and needs to have the same value as the field
  • date: must be a valid date time string according to strtotime()
  • date_format:Y-m-d H:i:s: must be a valid date time string according to the supplied format
  • different:other_field must have a different value than the other field
  • digits:X: must be a number and must have exactly X digits
  • digits_between:X,Y: must be a number and have between X and Y digits
  • email: must be a valid email address
  • in:one,two,three: the field value must be one of the arguments
  • in_array:other_field: field value must be one of the values of the other array field
  • integer ou int: must be an integer number
  • ip: must be a valid IP address
  • json: must be a valid JSON string
  • max:X: if field is an array, maximum number of elements, if it's a number, maximum allowed value, if it's a string, maximum length
  • min:X: if field is an array, minimum number of elements, if it's a number, minimum allowed value, if it's a string, minimum length
  • not_in:array_field: the field value must not be one of the values of the other array field
  • numeric: must be a number
  • present: must be present, but can be empty
  • regex:/abcd?/i: must validate against the supplied regexp
  • same:other_field: must have the same value as the other field
  • size:X: if field is an array, must have exactly X elements, if it's a number must have this value, if it's a string must be of X length
  • string: must be a string
  • timezone: must be a valid timezone name
  • url: must be a valid URL
  • after:2009-01-02: must be a date and that date must be after the supplied date
  • after_or_equal:2009-01-02: must be a date and that date must be after of the same as the supplied date
  • before:2009-01-02: must be a date and that date must be before the supplied date
  • before_or_equal:2009-01-02: must be a date and that date must be before or the same as the supplied date

Filter rules

  • int or integer transforms the field into an integer
  • date transforms field into a DateTime object
  • date_format:Y-m-d H:i:s transforms field into a DateTime object using supplied format
  • bool or boolean transforms into a boolean value
  • string transforms into a string and trims whitespaces and line returns from end and start of string