A different question on matchers too: if I use `no...
# general
s
A different question on matchers too: if I use
notEmpty()
with integer value (with protobuf plugin, but I think matchers are shared across plugins), I'm getting:
Copy code
Unable to match 123 using NotEmpty
So it seems like numbers are not match-able via notEmpty? How do we ensure that the number field is required?
r
The non-empty matcher gets applied to the value (mostly works with things like strings where the field is present but the empty string).
So, if a number field is present, it can never be empty.
So what you want to check for is that the field is not there at all. The problem with Protobuf is, if a field is missing, it will insert the default value (
0
,
false
,
""
, first enum value)
So the field will always be there, it will just have the default value if the other side did not send it.