Reputation: 525
I'm implementing a filter for a boolean value, but I want to have a default value, so for example.
parameter omitted - returns where isPublished=true
isPublished=true - return's where isPublished=true
isPublished=false - return's where isPublished=false
What If I want to return everything? I could do isPublished=all but some have complained that this is confusing as its not then a true boolean.
I could also go with Y/N/All or Either or Both
What are others views?
Upvotes: 0
Views: 1918
Reputation: 130997
Instead of a boolean
that restricts the values to true
and false
, you could consider using an enumeration and a parameter called status
or something similar to send its value to the server:
status = PUBLISHED | NOT_PUBLISHED | ALL
If the status
parameter is ommited, assume its value is PUBLISHED
. Otherwise, use the value provided in the parameter.
In the long run, using an enumeration will give you the possibility of expanding the available status.
Upvotes: 2