You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current validation methods are very long and wordy. They are very clear in meaning, e.g. mustMatchRegex, however, it makes Property builder strings soooo looong... I'm guessing the meanings are clear enough w/o the extra words.
I'd also like to purge deprecated methods with the 0.5.0 release, so if the old methods are going to be deprecated and renamed, perhaps it should be now in the 04.2 release. The actual change would be relatively easy.
In general, It makes sense to follow the pattern of existing methods. For String that is easy. Here are the current validation methods in StrProp and proposed new names:
Current Name
Proposed New Name
Notes
mustMatchRegex
matches
Same as String.matches(regex)
mustStartWith
startsWith
Same as String.startsWith(prefix)
mustStartWith
startsWith
Same as String.startsWith(prefix)
mustStartWithIgnoreCase
startsWithIgnoreCase
extension of startsWith
mustEndWith
endsWith
Same as String.endsWith(suffix) (sufix is misspelled on this method)
mustEndWithIgnoreCase
endsWithIgnoreCase
extension of startsWith
mustEqual(String...)
oneOf(String...)
'equals' cannot be used - There is no exact corollary.
mustBeNonNull
notNull()
No comp in the String class, but Junit uses assertNotNull
Missing from that list is oneOfIgnoreCase - This method is missing and should be another ticket.
Things are less clear for numeric Properties like IntProp, BigDecProp, etc. There is no obvious example to follow that I can think of. Here are some proposed method names a numeric Property, but I've no idea what the best and most clear names would be:
I agree, meanings are clear enough even without the extra words.
What about names from Mockito matchers for numeric Properties?
I don't really like it, just want to offer as an alternative.
@alex-kar Good thought - But I agree its perhaps a bit too terse. I wonder if those short method names could be added for people who want to use a more compact syntax? It might be a good future addition.
Mockito got me thinking of Hamcrest which I believe is in common use w/ JUnit. The Matchers class is very close to the AndHow method names with the 'must' removed:
Current Name
Proposed New Name
Notes
mustBeGreaterThan
greaterThan
mustBeGreaterThanOrEqualTo
greaterThanOrEqualTo
Hamcrest adds 'To'
mustBeLessThan
lessThan
mustBeLessThanOrEqualTo
lessThanOrEqualTo
Hamcrest adds 'To'
Hamcrest also has String matching that is close but slightly different. Here are key ones from their string matchers:
Current Name
Proposed New Name
Notes
mustEndWithIgnoreCase
endsWithIgnoringCase
Hamcrest has the 'ing'
mustStartWithIgnoreCase
startsWithIgnoringCase
Hamcrest has the 'ing'
mustEqual(String...)
oneOf(String...)
Same as above, but Hamcrest has it as well, so an added vote
So, I propose following the Hamcrest names for numerics and the String validation that have no corollary in the String class. What do you think? Are you interested in implementing it?
@eeverman Yes, I would like to take it. This task #587 just to rename those methods, but you mentioned missing oneOfIgnoreCase. Can you assign it to me as well if you're going to open new ticket? Thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Ref Issue #587
The current validation methods are very long and wordy. They are very clear in meaning, e.g.
mustMatchRegex, however, it makes Property builder strings soooo looong... I'm guessing the meanings are clear enough w/o the extra words.I'd also like to purge deprecated methods with the 0.5.0 release, so if the old methods are going to be deprecated and renamed, perhaps it should be now in the 04.2 release. The actual change would be relatively easy.
In general, It makes sense to follow the pattern of existing methods. For String that is easy. Here are the current validation methods in StrProp and proposed new names:
String.matches(regex)String.startsWith(prefix)String.startsWith(prefix)String.endsWith(suffix)(sufix is misspelled on this method)assertNotNullMissing from that list is
oneOfIgnoreCase- This method is missing and should be another ticket.Things are less clear for numeric Properties like IntProp, BigDecProp, etc. There is no obvious example to follow that I can think of. Here are some proposed method names a numeric Property, but I've no idea what the best and most clear names would be:
All reactions