You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import jakarta.validation.Constraint
@Retention(AnnotationRetention.RUNTIME)
@Constraint(validatedBy = [])
annotation class TimeOff(
@DurationPattern val maxDuration: String
)
Actual Behaviour
Given the following service
import jakarta.inject.Singleton
import jakarta.validation.constraints.NotBlank
import java.time.Duration
@Singleton
open class HolidayService {
open fun startHoliday(
@NotBlank person: String,
@TimeOff(maxDuration = "rubbish") duration: String // should give compile time error
): String = "Person $person is off on holiday for ${Duration.parse(duration).toDays()} days"
}
@TimeOff(maxDuration = "rubbish") does not fail compilation.
Expected Behavior
When following the docs here:
https://micronaut-projects.github.io/micronaut-validation/snapshot/guide/index.html#compileTimeValidation
I expect the below annotation to be validated
Actual Behaviour
Given the following service
@TimeOff(maxDuration = "rubbish")
does not fail compilation.Annotation DurationPattern is defined like this
DurationPatternValidator is defines like this
/src/main/resources/META-INF/services/io.micronaut.validation.validator.constraints.ConstraintValidator
Steps To Reproduce
Clone the example application and run
./gradlew clean build
Please observe that the tests are executed.
Environment Information
Ubuntu 22.04
JDK 21 (Temurin)
Example Application
https://github.com/roar-skinderviken/compile-time-validation-issue
Version
4.5.0
The text was updated successfully, but these errors were encountered: