should ow.string.equals
be narrowing the type to specific strings?
#235
Labels
ow.string.equals
be narrowing the type to specific strings?
#235
Problem
Use case: validating tagged json objects coming over the wire
Current workaround:
As far as I could tell, there's no built in way to do this as
StringPredicate#addValidator
andStringPredicate#validate
don't seem to let you change the type contained in the predicate.So, I created a custom predicate:
Possible solutions:
A. Generify
ow.string.equals
Currently this doesn't allow any further narrowing:
It could possibly be:
This does prevent any further chaining onto that predicate, but one could argue that a string matching
equals
cannot be further validated. Certainly none of the other included validators can give you any more useful informationB. Generify
StringPredicate
If one wanted to maintain chaining, could do something like this:
Thus the returned type would still be a
StringPredicate
.C. Some other better solution ? ? ?
The text was updated successfully, but these errors were encountered: