-
Notifications
You must be signed in to change notification settings - Fork 843
#2735 - replacement of ModelValidation #2804
Conversation
new Validator[V2Group] { | ||
override def apply(group: V2Group): Result = { | ||
conf.maxApps.get.map { num => | ||
RuleViolation(group, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you compare num to the number of apps ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you are right. I committed a change on that.
What do you think @kolloch @meichstedt @gkleiman ?? |
@Alexanderweber I just read your nice summary and it looks very good. You say that the new error messages "look very similar". Does that mean they contain the same JSON fields in error responses, just that the messages are slightly different? We should only add fields to the JSON wherever possible to keep compatibility. Furthermore, I would like to ensure that the following things are possible (I would expect it but better be certain). You don't have to address them at once in the patch, I am more interested in feasibility.
{
"errors": [
{
"attribute": "dependencies.[0].path",
"errorCode": "string.maxLengthExceeded", // just a silly example
"errorArgs": {
"value": "/this/is/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/long/for/a/path",
"maxLength": 256
},
"error": "The value '/this/is/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/really/long/for/a/path' exceed the maximum length of 256 characters."
}
]
} That design allows automated parsing of errors and also allows (optionally) I18n by the frontend.
|
@kolloch Hey Peter, I did mean exactly that - JSON field names will stay the same, but the content of messages might be slightly different.
|
@kolloch Regarding error codes: The lack of error codes respectively missing documentation of those has actually been a demand of a customer. I´m going to create a separate story for implementation and documentation. |
Merged master into this branch. Checks passed. @aquamatthias Please get back to me if you are ready to merge this pull request. |
.getOrElse(Response.created(new URI(appId.toString))) | ||
maybePostEvent(req, plan.target.app(appId).get) | ||
deploymentResult(plan, response) | ||
// TODO AW: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove comment or test?
@wendigo Nice to hear. Let me know if you'll have any issues using the new approach. I am hoping for a merge during today. |
hc is validProtocol | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment here is:
- outdated: since the problem with the seq is not valid any longer
- in the wrong place: it probably should be moved to V2AppUpdate.appDefinitionValidator, where we don't do
appDef.healthChecks is valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aquamatthias Regarding your second remark: do you mean the comment should be moved to appDefintionValidator? I did do so in c4cb9e2, it is now in V2AppDefinition.appDefinitionValidator
.
45e0152
to
de4fe79
Compare
de4fe79
to
0affcaa
Compare
0affcaa
to
c4cb9e2
Compare
@Alexanderweber sure thing! |
@@ -1,234 +0,0 @@ | |||
package mesosphere.marathon.api.validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Alexanderweber sorry that I did not mention that before: why did you remove the whole test class here? Would it not make sense to use the new validation logic here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aquamatthias Sorry for late reply. As I was deleting the whole validation
folder with annotation validation, I did not pay attention, that there was also one test included in there. Sorry for that, I added it back again adjusting it to new validation model. I need to merge the master into the branch again, I'll do so by the end of the day.
c4cb9e2
to
e910451
Compare
@Alexanderweber: Thanks. Please rebase. |
e910451
to
f9b2daa
Compare
This is a great addition. Thanks! |
#2735 - replacement of ModelValidation
Nice! :) |
Hi everyone, sorry to raise the dead but I missed the original discussion when it was still ongoing. I'm the maintainer of Accord, and would absolutely love your input on how to add these features cleanly! In particular, Accord is currently quite naïve about how it handles violations, in that it simply encodes them as strings. There's an open issue (wix-incubator/accord#21) that deals with the various implementation options, but lacking external input I was never sufficiently happy with any of them. It's a somewhat long-winded discussion, but if you have some fresh ideas on what this should look like (e.g. how to maintain type safety and/or offer a clean DSL), please do weigh in! There's also a Gitter channel if you prefer the more personal touch. Lastly, I'm curious about the "path" generation/transformation properties mentioned by @kolloch; Accord automatically generates a string description for each "thing" being validated. A "thing" could be property access, modifier ( Thank you for trying out Accord, I hope you've been enjoying it so far! |
This also appears to have broken relative paths in dependencies, or at least changed how they are represented.
I have this in my deployment of a selenium grid, and this worked before 0.15.3, but doesn't now. How do you represent this relatively now? All the examples and tests seem to be full path, which I would rather not do for what I think would think would be relatively obvious reasons. |
@aquamatthias @kolloch @gkleiman @meichstedt Hey guys, we decided to give Accord Validation a try and replace our ModelValidation, which was still using Java's BeanValidation. The new library is capable of keeping track of the path down to the occurrence of the error. It is also using macros and detects property names automatically, so there is no need in propagating them explicitly. Validation rules can be constructed in an easy manner like this:
As it is an implicit validator, you could easily validate an
appDefinition
from typeV2AppDefinition
like this:We already tried the new validation out on some API methods. E.g. a following POST request in /v2/apps
will return an error sequence, which looks very similar to the one we are already used to:
How do you feel about the new way of validating objects? You could have a look at e.g.
AppsResource.scala
in order to see the new validation in action.