{"action":"created","issue":{"url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/20","repository_url":"https://api.github.com/repos/katharsis-project/katharsis-core","labels_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/20/comments","events_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/20/events","html_url":"https://github.com/katharsis-project/katharsis-core/issues/20","id":68472300,"number":20,"title":"Add Bean Validation","user":{"login":"meshuga","id":1073936,"avatar_url":"https://avatars.githubusercontent.com/u/1073936?v=3","gravatar_id":"","url":"https://api.github.com/users/meshuga","html_url":"https://github.com/meshuga","followers_url":"https://api.github.com/users/meshuga/followers","following_url":"https://api.github.com/users/meshuga/following{/other_user}","gists_url":"https://api.github.com/users/meshuga/gists{/gist_id}","starred_url":"https://api.github.com/users/meshuga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meshuga/subscriptions","organizations_url":"https://api.github.com/users/meshuga/orgs","repos_url":"https://api.github.com/users/meshuga/repos","events_url":"https://api.github.com/users/meshuga/events{/privacy}","received_events_url":"https://api.github.com/users/meshuga/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/katharsis-project/katharsis-core/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-04-14T19:14:04Z","updated_at":"2016-02-15T04:42:31Z","closed_at":null,"body":"Add bean validation (JSR 303) mechanism."},"comment":{"url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/comments/184064555","html_url":"https://github.com/katharsis-project/katharsis-core/issues/20#issuecomment-184064555","issue_url":"https://api.github.com/repos/katharsis-project/katharsis-core/issues/20","id":184064555,"user":{"login":"keithdmoore","id":954458,"avatar_url":"https://avatars.githubusercontent.com/u/954458?v=3","gravatar_id":"","url":"https://api.github.com/users/keithdmoore","html_url":"https://github.com/keithdmoore","followers_url":"https://api.github.com/users/keithdmoore/followers","following_url":"https://api.github.com/users/keithdmoore/following{/other_user}","gists_url":"https://api.github.com/users/keithdmoore/gists{/gist_id}","starred_url":"https://api.github.com/users/keithdmoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keithdmoore/subscriptions","organizations_url":"https://api.github.com/users/keithdmoore/orgs","repos_url":"https://api.github.com/users/keithdmoore/repos","events_url":"https://api.github.com/users/keithdmoore/events{/privacy}","received_events_url":"https://api.github.com/users/keithdmoore/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T04:42:31Z","updated_at":"2016-02-15T04:42:31Z","body":"@meshuga @masterspambot @ieugen  I managed to figure out how to make a Spring based, Kartharsis infused application invoke validations.  AKA: Without any kartharsis-core changes.\r\n\r\nI can add this to the katharsis-spring project.  I think it would be a nice example.\r\n\r\n1. Add beans to application config\r\n```java\r\n@Configuration\r\npublic class AppConfig {\r\n\r\n    @Bean\r\n    public MethodValidationPostProcessor methodValidationPostProcessor() {\r\n        final MethodValidationPostProcessor methodValidationPostProcessor = new MethodValidationPostProcessor();\r\n        methodValidationPostProcessor.setValidator(validator());\r\n        return methodValidationPostProcessor;\r\n    }\r\n\r\n    @Bean\r\n    public LocalValidatorFactoryBean validator() {\r\n        final LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();\r\n        return localValidatorFactoryBean;   \r\n    }\r\n}\r\n```\r\n2. Add @Validated to TaskRepository and add @Valid to entity parameter\r\n```java\r\n@Component\r\n@JsonApiResourceRepository(Task.class)\r\n@Transactional\r\n@Validated\r\npublic class TaskRepository {\r\n    @JsonApiSave\r\n    public <T extends MemberDto> T save(@Valid T entity) {\r\n       return entity;\r\n    }\r\n}\r\n```\r\n3. Add custom ExceptionMapper.  Need to map the attributes accordingly.\r\n```java\r\n@ExceptionMapperProvider\r\npublic class ConstraintViolationExceptionMapper implements JsonApiExceptionMapper<ConstraintViolationException> {\r\n  \r\n  @Override\r\n  public ErrorResponse toErrorResponse(ConstraintViolationException exception) {\r\n    List<ErrorData> errors = new ArrayList<>();\r\n    for (ConstraintViolation<?> violation : exception.getConstraintViolations()) {\r\n        ErrorData error = ErrorData.builder().setStatus(String.valueOf(CONFLICT_409))\r\n        .setTitle(violation.getMessage())\r\n        .setDetail(violation.toString()).build();\r\n        errors.add(error);\r\n    }\r\n    \r\n    return ErrorResponse.builder()\r\n      .setStatus(CONFLICT_409)\r\n      .setErrorData(errors)\r\n      .build();\r\n  }\r\n}\r\n```"}}