Skip to content

Compare to another field value #111

@jhuet

Description

@jhuet

I'm trying to compare if the value i'm validating is the same as the value in another field. A basic example would be a password confirmation. Is there a way to do so ?

If not, i think a nice way to implement it would be to make it available in actual rules instead of making a new one. For example the equal rule could accept a raw value like now or a reference to another field. Same with between, lengthBetween, lessThan and even why not inArray ?

To make a distinction with a raw value we could use the & character like in PHP. So if i do $v->required('foo')->lengthBetween(0, '&bar'); it would actually compare in between 0 and the value of bar field. Same for : $v->required('foo')->equals('&bar'); it'd check if it's equal to the value of bar field.

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions