Skip to content

Add reference support for String.min/max/length#597

Closed
DavidTPate wants to merge 7 commits intohapijs:masterfrom
DavidTPate:feature/string-ref-min-max-length
Closed

Add reference support for String.min/max/length#597
DavidTPate wants to merge 7 commits intohapijs:masterfrom
DavidTPate:feature/string-ref-min-max-length

Conversation

@DavidTPate
Copy link
Contributor

This PR adds support for using references or String min(), max(), length() and the supporting documentation.

@DavidTPate
Copy link
Contributor Author

Currently, this build fails due to keys in the object being validated being in a different order than they were previously. I didn't update this test because I want to look into the root cause to see why my changes caused this to occur.

@Marsup
Copy link
Collaborator

Marsup commented Mar 10, 2015

Don't trust the diff, it only compares both stringifications, which can happen in different orders, but there's still something different somewhere.

@Marsup Marsup added the feature New functionality or improvement label Mar 10, 2015
@Marsup Marsup added this to the 6.1.0 milestone Mar 10, 2015
@Marsup Marsup self-assigned this Mar 10, 2015
@DavidTPate
Copy link
Contributor Author

@Marsup So I figured out what caused it to change the order, still trying to understand why. The extra variable encoding which I was passing causes the variables within the context to be added in a different order. Removing encoding from the context for the error makes the test pass, and moving the limit and value variables around causes the tests to fail once more since the context is constructed differently yet again.

I think the passing the encoding to the error so that it can be used in custom error messages is useful. I could update the part in the compare property where errors are created to only add encoding if it is truthy, but that's not how the rest of the library creates errors.

I added encoding back and updated the tests to have the keys in the new order for when encoding is included. This makes the objects the same but Hoek is still reporting them as not being equal...it really seems like no matter the order of the keys Hoek should consider them to be deeply equal, but that's a different problem.

@DavidTPate
Copy link
Contributor Author

Previous tests failed because encoding was being included in the context as undefined but wasn't included in the expected values. The assertions don't show the difference because the assertion only asserts that the value should be undefined and therefore doesn't display it.

@Marsup
Copy link
Collaborator

Marsup commented Mar 11, 2015

Like I told you, the order doesn't matter, if you have an error there is something different.

@Marsup
Copy link
Collaborator

Marsup commented Mar 11, 2015

Seems OK, can you squash all those commits ?

@DavidTPate
Copy link
Contributor Author

@Marsup Should be squashed now, first time doing it but I think I got it. I guess GitHub still shows the older commits that occurred, but my repo only shows them as the new squashed commit.

@Marsup
Copy link
Collaborator

Marsup commented Mar 11, 2015

Nope, github should show only one commit, it seems you did a merge with yourself, I don't know what happened here :)

@DavidTPate
Copy link
Contributor Author

Yeah, I think it was my lack of knowledge squashing stuff. When I pushed Webstorm had me choose Merge/Rebase after I squashed everything. I chose merge, and it merged to itself and undid what I squashed.

I've been trying to undo the merge or squash all of the things together again, but I just can't seem to figure it out.

@Marsup
Copy link
Collaborator

Marsup commented Mar 12, 2015

I'll merge it manually then. Anyway I want to change the target since merging to master would keep me from releasing further 6.0.x versions.

@Marsup
Copy link
Collaborator

Marsup commented Mar 12, 2015

Merged in branch 6.1.0.

@Marsup Marsup closed this Mar 12, 2015
@DavidTPate
Copy link
Contributor Author

Cool, thanks @Marsup !

@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants