Les variables payload dans les annotations de validation sont nécessaires.

This commit is contained in:
FyloZ 2021-03-09 15:56:00 -05:00
parent faeff20272
commit c5d3791460
2 changed files with 6 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package dev.fyloz.trial.colorrecipesexplorer.model.validation
import javax.validation.Constraint
import javax.validation.ConstraintValidator
import javax.validation.ConstraintValidatorContext
import javax.validation.Payload
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlin.reflect.KClass
@ -14,7 +15,8 @@ private const val MESSAGE = "must be null or not blank"
@Constraint(validatedBy = [NullOrNotBlankValidator::class])
annotation class NullOrNotBlank(
val message: String = MESSAGE,
val groups: Array<KClass<*>> = []
val groups: Array<KClass<*>> = [],
@Suppress("unused") val payload: Array<KClass<out Payload>> = []
)
class NullOrNotBlankValidator : ConstraintValidator<NullOrNotBlank, String> {

View File

@ -3,6 +3,7 @@ package dev.fyloz.trial.colorrecipesexplorer.model.validation
import javax.validation.Constraint
import javax.validation.ConstraintValidator
import javax.validation.ConstraintValidatorContext
import javax.validation.Payload
import kotlin.reflect.KClass
private const val MIN_SIZE = Long.MIN_VALUE
@ -16,7 +17,8 @@ annotation class NullOrSize(
val min: Long = MIN_SIZE,
val max: Long = MAX_SIZE,
val message: String = MESSAGE,
val groups: Array<KClass<*>> = []
val groups: Array<KClass<*>> = [],
@Suppress("unused") val payload: Array<KClass<out Payload>> = []
)
class NullOrSizeValidator : ConstraintValidator<NullOrSize, Any> {