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

Validation proposals #71

Open
1 of 34 tasks
ndrwrbgs opened this issue Nov 15, 2017 · 15 comments
Open
1 of 34 tasks

Validation proposals #71

ndrwrbgs opened this issue Nov 15, 2017 · 15 comments
Labels

Comments

@ndrwrbgs
Copy link
Contributor

ndrwrbgs commented Nov 15, 2017

Paths

make sure work here includes thoughts about how to handle the case where Directory method is called but a File exists at the path

  • DirectoryExists
  • DirectoryDoesNotExist
  • FileExists
  • FileDoesNotExist

Object

  • IsNull (though Is(null) probably suffices)
  • Implements/Extends
  • IsAnyOf (analogous to Is)
  • IsNotAnyOf

Number

  • IsApproximately(accuracy/within)
  • IsPositive
  • IsNegative
  • IsNotNegative

Collection

  • SizeIsGt/Lt/Gte/Lte
  • SizeIsNot
  • Contains
  • DoesNotContain
  • ^variation of above | HasNoNull
  • ContainsExactly(2, [optional] where: item => item == "foo")
  • IsEmpty (.SizeIs(0))
  • IsInAscendingOrder (IComparable only)
  • IsInDescendingOrder (IComparable only)

Dictionary

  • DoesNotContainKey
  • ContainsValue
  • DoesNotContainsValue

String

@ndrwrbgs
Copy link
Contributor Author

For the String and Collection SizeIs methods, they seem redundant since users could use Ensure.That(str.Length).IsGt(4). However I would suggest either feature parity (if exposing SizeIs, also expose Gt/Lt/!=), or not exposing any of them and forcing access via string.Length

@ndrwrbgs ndrwrbgs changed the title New validations Validation proposals Nov 15, 2017
@ndrwrbgs
Copy link
Contributor Author

@danielwertheim I'm game to work on any/all of these if/as you approve of them, just let me know if you think they'd be valuable contributions.

@danielwertheim
Copy link
Owner

Haven't had time to look through this yet. Want to finalize 7.1 first so that it gets merged to master.

Also, before doing this, a decision to revoke the Ensure.That(...,...).Foo() or not need to be taken.

@dmarciano
Copy link

Hi...I'm interested in contributing to this, specifically working on the numbers (IsApproximately, IsPosition, etc.). I didn't see any PR guidelines in the repo, so I was just wondering, would it be preferred that each implementation has its own PR or could I implement all four methods under the Number category and submit a single pull request for all of them?

@danielwertheim
Copy link
Owner

@dmarciano the smaller the better. Preferably one PR per feature if OK.

@dmarciano
Copy link

I have implemented the IsPositive, IsNegative, IsNotNegative, and IsApproximately methods and extension methods, along with 16 new unit tests to cover these methods (all of which have passed successfully).

The project's coding style is a little different to how I usually code, but I tried to match the pattern/style as closely as possible with my new code. If there is anything off, or you would prefer I change, please let me know.

@ndrwrbgs
Copy link
Contributor Author

ndrwrbgs commented Dec 8, 2019

Most of these implemented in the -Experimental library
RE my comment in #125 I worked around it by allowing the user to specify how to handle 0, if you wanted to do similarly @dmarciano

@dmarciano
Copy link

@ndrwrbgs Yes...I saw your comment but haven't had a chance to review the link you provided yet as I'm traveling today. I should be able to look at it first thing tomorrow morning and either give feedback or start work on a change for it. I'll keep you posted.

@ndrwrbgs
Copy link
Contributor Author

ndrwrbgs commented Dec 8, 2019

Linked in the other convo (was trying to avoid 'advertising' as that isn't the intention here) but will link just for your ease since you're traveling :-P
I implemented samples here: https://github.com/ndrwrbgs/Ensure.That.Experimental

@danielwertheim
Copy link
Owner

@ndrwrbgs what's in experimental that can't be in the public repo?

@dmarciano
Copy link

dmarciano commented Dec 9, 2019

@ndrwrbgs I have implemented the solution similar to experiemental repo you provided by creating a new enum ZeroSignMode and adding optional parameters which defaults to ZeroSignMode.IsNeither (other values possible are ZeroSignMode.IsPositive, ZeroSignMode.IsNegative, and ZeroSignMode.IsBoth).

I am currently working on updating the unit tests to confirm that everything still works as well as the new logic for zeros. I should have a commit ready in the next few hours.

@ndrwrbgs
Copy link
Contributor Author

ndrwrbgs commented Dec 9, 2019 via email

@dmarciano
Copy link

dmarciano commented Dec 9, 2019

@ndrwrbgs Out of curiosity, did you implement the SizeIsNot, SizeIsGt/Lt/Gte/Lte, IsAscendingOrder/IsDescendingOrder methods in your experimental library? Just wondering because I created a new branch in my repo and I just implemented these; currently working on just adding all the unit tests. But if you've already implemented these methods, along with other ones on this list, I guess it doesn't make sense for me to re-do it.

@dmarciano
Copy link

On another note, for the IsInAscendingOrder/IsInDescendingOrder , for the IDictionary interface, I'm assuming the ascending/descending order is for the keys?

@ndrwrbgs
Copy link
Contributor Author

ndrwrbgs commented Dec 10, 2019 via email

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

No branches or pull requests

3 participants