Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for comparing two properties #114

Open
paw3lx opened this issue Nov 18, 2017 · 8 comments
Open

Support for comparing two properties #114

paw3lx opened this issue Nov 18, 2017 · 8 comments

Comments

@paw3lx
Copy link
Collaborator

paw3lx commented Nov 18, 2017

I think it could be nice to have ability to compare two properties of an object:

.Ensure(m => m.Password, _ => _.IsEqualTo(m => m.RePassword))

What do you think about it?

@GooRiOn
Copy link
Member

GooRiOn commented Nov 18, 2017

Yup, that looks cool. Do you want to create an overload for each binary operation, or just IsEqualTo() ?

@paw3lx
Copy link
Collaborator Author

paw3lx commented Nov 23, 2017

It will be great to create overload for IsLessThan() and IsGreaterThan() too.

@arekbal
Copy link
Contributor

arekbal commented Nov 26, 2017

@paw3lx That would be also useful with BeginDate/EndDate/BeginTime/EndTime validations where one have to predate the other.
But, wouldn't adding another overload to Ensure() with another argument(model) achieve the same with somehow cleaner syntax? Like
.Ensure(m => m.RePassword, (_, m) => _.IsEqualTo(m.Password))

Or both could be made available but I think promoting single 'best' way of doing stuff is the right idea.

BTW. I don't like underscore arg names in our code and in examples. Because: "That is a convention used when you don't care about the parameter.".
https://stackoverflow.com/questions/2778362/what-does-this-mean-in-lambda-expressions

@paw3lx
Copy link
Collaborator Author

paw3lx commented Nov 27, 2017

@GooRiOn What do you think about @arekbal syntax?

@GooRiOn
Copy link
Member

GooRiOn commented Nov 27, 2017

I'd go for Arek's suggestion mostly because that is fairly simple to implement and does what it should. I also agree that we should promote "best way" of doing something instead of "couple fine" ways. The only problem I have is that the old syntax will be depricated (at the second version) :D

On the one hand we don't have a lot of "fame" right now so "the soon the better". But on the other, it could piss off all folks that use that.

@dbarwikowski I summon you !

@GooRiOn GooRiOn mentioned this issue Dec 7, 2017
1 task
@arekbal arekbal changed the title Suppor for comparing two properties Support for comparing two properties Dec 10, 2017
@GooRiOn GooRiOn added the 1.0.0 label Dec 13, 2017
@GooRiOn GooRiOn added this to the 1.3.0 milestone Dec 17, 2017
@GooRiOn GooRiOn removed the 1.0.0 label Mar 31, 2018
@dbarwikowski
Copy link
Member

I prefer @paw3lx syntax. I think it's more human friendly and easier to remember.

@arekbal what would you suggest to use instead of '_'?

@arekbal
Copy link
Contributor

arekbal commented Apr 3, 2018

'x', 'a', 'v' ?

@arekbal arekbal closed this as completed Apr 3, 2018
@arekbal arekbal reopened this Apr 3, 2018
@dbarwikowski
Copy link
Member

'()' ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants