@@ -14,15 +14,17 @@ import io.swagger.v3.oas.annotations.Operation
1414import io.swagger.v3.oas.annotations.tags.Tag
1515import org.springframework.cache.CacheManager
1616import org.springframework.http.ResponseEntity
17+ import org.springframework.validation.annotation.Validated
1718import org.springframework.web.bind.annotation.*
1819import javax.validation.Valid
20+ import javax.validation.constraints.Min
1921import javax.validation.constraints.Size
2022
2123/* *
2224 * date: 23.12.19
2325 * @author Lucy Linder <lucy.derlin@gmail.com>
2426 */
25-
27+ @Validated
2628@RestController
2729@RequestMapping(" /objects" )
2830@Tag(name = " Objects Tokens" , description = " Manage object tokens" )
@@ -32,10 +34,11 @@ class ObjectsTokenController(private val objectsAccessManager: ObjectsAccessMana
3234
3335
3436 data class BulkTokenBody (
35- @NotNull
37+ @field:javax.validation.constraints.NotNull
38+ @field:Min(value = 0, message = "objectId must be positive.")
3639 val objectId : Long = 0 ,
3740
38- @Size(max = Beans .DESCRIPTION_MAX )
41+ @field: Size(max = Beans .DESCRIPTION_MAX )
3942 val description : String? = null
4043 )
4144
@@ -82,7 +85,7 @@ class ObjectsTokenController(private val objectsAccessManager: ObjectsAccessMana
8285 @PutMapping(" bulk/tokens" )
8386 fun addObjectTokenBulk (
8487 @UserId userId : Int ,
85- @Valid @RequestBody tokenBodies : List <BulkTokenBody >): MutableList <Token > {
88+ @Valid @NotNull @ RequestBody tokenBodies : List <@Valid BulkTokenBody >): MutableList <Token > {
8689
8790 tokenBodies.forEach {
8891 // ensure rights
0 commit comments