-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide rule when a default parameter value should be used #12
Comments
I added a first implementation with commit 35a1f81. |
I like the feature, but would like to see if we can keep the AST clean by moving the validation to the parsers. The question arises what to do when a value parses, but fails validation? In that case I think we need a ternary representation for the return value. Something like sealed trait ParseResult[T] {
def flatMap(... blah blah... ) ...
}
case class ParseFail(error: String) extends ParseResult[Nothing]
case class ValidationFail(error: String) extends ParseResult[Nothing]
case class Success[T](value: T) extends ParseResult[T] |
Sounds good. We should do that improvement. Than I can also solve other issues more easily. |
There are two schools of thought concerning handling error in the presence of a default. |
The tests are brought into compliance with commit 7c2bbc7. |
I'm with you and prefer the 2 over 1. This makes my use cases much easier instead of working with |
I feel like this should be closed. If thats not true, feel free to reopen. |
I thought a bit about the current behavior and have the following question: Do we want to use the default value in case a number is expected but cannot be parsed? Maybe this is more handy? |
We have the following possibilities when querying for an
In summary, I think we should only use the default when a value has not been presented, and never when an invalid value has been presented. The client should be alerted to their mistake so they can fix their behavior, not given a result which they may not have intended to fetch. Are there good reasons for behavior contrary to that above? |
Make sense to behave as you described it. Maybe we can improve the HTTP response by providing a better status code. A JSON-representation with a message would be nice but should be defined by the user itself. Okay, now I have it. A user should be able to define a strategy/function in case the value is not parseable. Does it make sense? |
Yes, a failure strategy would be nice. We should make an issue for that and
|
We work in a new branch for that feature. |
Lets say we have the following query parameters
and we want to apply the default values always if a given predicate evaluates
true
.The text was updated successfully, but these errors were encountered: