Skip to content
Snippets Groups Projects
Commit f62e64c8 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

add some validation e.g. article title length

parent f3eed9fe
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedList;
......@@ -96,7 +97,7 @@ public class ArticlesApi {
@ApiResponses(value = { @ApiResponse(code = 201, message = "Article created") })
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Void> addAnArticle(
@RequestBody @ApiParam(value = "Article to create", required = true) Article article
@RequestBody @ApiParam(value = "Article to create", required = true) @Valid Article article
) {
User user = mipApplication.getUser();
......@@ -199,7 +200,7 @@ public class ArticlesApi {
@RequestMapping(value = "/{slug}", method = RequestMethod.PUT)
public ResponseEntity<Void> updateAnArticle(
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug,
@RequestBody @ApiParam(value = "Article to update", required = true) Article article
@RequestBody @ApiParam(value = "Article to update", required = true) @Valid Article article
) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
......
......@@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
......@@ -22,6 +24,8 @@ public class Article {
@Id
private String slug = null;
@NotNull
@Size(min = 1, max = 255)
private String title = null;
private String status = null;
......
......@@ -51,6 +51,7 @@ public class Model {
@JoinColumn(name = "updatedby_username")
private User updatedBy = null;
@Column(columnDefinition = "text")
private String textQuery = null;
......
db @ 9f22b032
Subproject commit 6b833cfe795c98e6a6bcdcc17002b706d3f6d2ce
Subproject commit 9f22b032e0f4728c5e46fa157b9db04b55c5f8e6
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment