{"action":"created","issue":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3042","repository_url":"https://api.github.com/repos/jhipster/generator-jhipster","labels_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3042/labels{/name}","comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3042/comments","events_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3042/events","html_url":"https://github.com/jhipster/generator-jhipster/issues/3042","id":137583095,"number":3042,"title":"saveAccount REST API doesn't use JSR 303 validation rules on DTO Layer","user":{"login":"gbrehmer","id":1201680,"avatar_url":"https://avatars.githubusercontent.com/u/1201680?v=3","gravatar_id":"","url":"https://api.github.com/users/gbrehmer","html_url":"https://github.com/gbrehmer","followers_url":"https://api.github.com/users/gbrehmer/followers","following_url":"https://api.github.com/users/gbrehmer/following{/other_user}","gists_url":"https://api.github.com/users/gbrehmer/gists{/gist_id}","starred_url":"https://api.github.com/users/gbrehmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbrehmer/subscriptions","organizations_url":"https://api.github.com/users/gbrehmer/orgs","repos_url":"https://api.github.com/users/gbrehmer/repos","events_url":"https://api.github.com/users/gbrehmer/events{/privacy}","received_events_url":"https://api.github.com/users/gbrehmer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-01T14:09:33Z","updated_at":"2016-03-02T17:30:51Z","closed_at":null,"body":"##### **Overview of the issue**\r\n\r\nREST API for saveAccount throws internal errors in case of validation problems (produced by hibernate check of JSR 303 annotations)\r\n\r\n##### **Motivation for or Use Case** \r\n\r\nAccountResource#saveAccount should have the same validation-rules applied to the given DTO like AccountResource#registerAccount (except password)\r\n\r\n##### **JHipster Version(s)** \r\n\r\n2.27.0\r\n\r\n##### **Reproduce the error** \r\n\r\nUsing api/account with a REST Client & invalid POST body (e.g. missing values)\r\n\r\n##### **Suggest a Fix** \r\n\r\nUse different DTOs for registration and changing account settings. Annotate POST Body Entity with @Valid annotation to enable JSR 303 validation rules.\r\n"},"comment":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/comments/191340032","html_url":"https://github.com/jhipster/generator-jhipster/issues/3042#issuecomment-191340032","issue_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3042","id":191340032,"user":{"login":"notflorian","id":409484,"avatar_url":"https://avatars.githubusercontent.com/u/409484?v=3","gravatar_id":"","url":"https://api.github.com/users/notflorian","html_url":"https://github.com/notflorian","followers_url":"https://api.github.com/users/notflorian/followers","following_url":"https://api.github.com/users/notflorian/following{/other_user}","gists_url":"https://api.github.com/users/notflorian/gists{/gist_id}","starred_url":"https://api.github.com/users/notflorian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/notflorian/subscriptions","organizations_url":"https://api.github.com/users/notflorian/orgs","repos_url":"https://api.github.com/users/notflorian/repos","events_url":"https://api.github.com/users/notflorian/events{/privacy}","received_events_url":"https://api.github.com/users/notflorian/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T17:30:51Z","updated_at":"2016-03-02T17:30:51Z","body":"I don't think this is very efficient to have 2 DTO, one with password validation and one without.\r\n\r\nMaybe we could remove the `@NotNull` and `@Size(min = PASSWORD_MIN_LENGTH, max = PASSWORD_MAX_LENGTH)` and validate the password explicitly in `AccountResource#registerAccount`.\r\n\r\nAn other solution could be in `AccountResource#saveAccount` to validate selectively the fields email, firstName, lastName and langKey, but I don't know how to do that. \r\nMaybe with the `@Validated` anotation like explained here : http://blog.codeleak.pl/2012/03/how-to-method-level-validation-in.html ?\r\n\r\nDoes anybody has a better idea to fix it?"}}