Packages

package cfg

Type Members

  1. case class ConstraintMapping(annotationType: Class[_ <: Annotation], constraintValidator: Class[_ <: ConstraintValidator[_ <: Annotation, _]], includeExistingValidators: Boolean = true) extends Product with Serializable

    Simple configuration class for defining constraint mappings for ScalaValidator configuration.

    Simple configuration class for defining constraint mappings for ScalaValidator configuration.

    Usage

    val customConstraintMapping: ConstraintMapping =
      ConstraintMapping(classOf[Annotation], classOf[ConstraintValidator])
    
    val validator: ScalaValidator =
      ScalaValidator.builder
        .withConstraintMapping(customConstraintMapping)
        .validator

    or multiple mappings

    val customConstraintMapping1: ConstraintMapping = ???
    val customConstraintMapping2: ConstraintMapping = ???
    
    val validator: ScalaValidator =
      ScalaValidator.builder
        .withConstraintMappings(Set(customConstraintMapping1, customConstraintMapping2))
        .validator
    annotationType

    the Class[Annotation] of the constraint annotation.

    constraintValidator

    the implementing ConstraintValidator class for the given constraint annotation.

    includeExistingValidators

    if this is an additional validator for the given constraint annotation type or if this should replace all existing validators for the given constraint annotation type. Default is true (additional).

    Note

    adding multiple constraint mappings for the same annotation type will result in a ValidationException being thrown.

Ungrouped