Class LinkedCourseValidator
java.lang.Object
edu.ucsb.cs156.frontiers.validators.LinkedCourseValidator
- All Implemented Interfaces:
jakarta.validation.ConstraintValidator<HasLinkedCanvasCourse,Course>
public class LinkedCourseValidator
extends Object
implements jakarta.validation.ConstraintValidator<HasLinkedCanvasCourse,Course>
This is a validator, which enforces a property. These are used together with @Validated to in a
spring managed bean (for example, a controller or service).
With this validator, you would have to put lots of code in your controller to check for linked courses. Instead, we can just put @HasLinkedCanvasCourse on the method parameters that require it, and if the contraint is not satisfied, a ConstraintViolationException will be thrown.
-
Constructor Details
-
LinkedCourseValidator
public LinkedCourseValidator()
-
-
Method Details
-
isValid
public boolean isValid(Course course, jakarta.validation.ConstraintValidatorContext constraintValidatorContext) - Specified by:
isValidin interfacejakarta.validation.ConstraintValidator<HasLinkedCanvasCourse,Course>
-