Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Validate field based on another fields setting
  • Hi,

    Is it possible to validate a field based off what another fields value is?

    For instance, I need to validate that an email address is specified if the field contact_type is email.

    I'm pretty sure there is no rule built in for this, but would it even be possible with a custom rule?
    Possibly using Input::post() directly? (I think to myself as writing I'm this)

    Otherwise I suppose I will just have write my own validation class, but I'd prefer to be able to validate a model with access to all its values.
  • You can do that in the validation rule.

    "match_field" and "required_with" are two examples of existing validation rules that validate based on a second field value.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion