override def validateField[T]()

in scrooge-core/src/main/scala/com/twitter/scrooge/UtilValidator.scala [31:72]


  override def validateField[T](
    fieldName: String,
    fieldValue: T,
    fieldAnnotations: Map[String, String]
  ): Set[ThriftValidationViolation] = {
    val constraints = fieldAnnotations.flatMap {
      case (annotationKey, annotationValue) =>
        // 4 default annotations require an annotation value:
        // "validation.size": applies to container types, requires an annotation type `int`.
        // "validation.length": applies to String, requires an annotation type `int`.
        // "validation.min": applies to numeric types, requires an annotation type `long`.
        // "validation.max": apply to numeric types, requires an annotation type `long`.
        // the annotation types are checked and enforced at compile time.
        if (annotationKey.startsWith("validation.size")) {
          sizeAndLengthConstraints(fieldAnnotations, "validation.size.min", "validation.size.max")
        } else if (annotationKey.startsWith("validation.length")) {
          sizeAndLengthConstraints(
            fieldAnnotations,
            "validation.length.min",
            "validation.length.max")
        } else if (annotationKey.startsWith("validation.min")) {
          // it is safe to call `toLong` since the annotation value
          // types are checked and enforced at compile time.
          Map[Class[_ <: Annotation], Map[String, Long]](
            classOf[Min] -> Map("value" -> annotationValue.toLong))
        } else if (annotationKey.startsWith("validation.max")) {
          // it is safe to call `toLong` since the annotation value
          // types are checked and enforced at compile time.
          Map[Class[_ <: Annotation], Map[String, Long]](
            classOf[Max] -> Map("value" -> annotationValue.toLong))
        } else if (annotationIsDefined(annotationKey)) {
          Map[Class[_ <: Annotation], Map[String, Any]](
            DefaultAnnotations.metadata(annotationKey).jakartaAnnotation -> Map.empty[String, Any])
        } else {
          Set.empty
        }
    }

    scalaValidator
      .validateFieldValue(constraints, fieldName, fieldValue)
      .map(violation => ThriftValidationViolation(fieldName, fieldValue, violation.getMessage))
  }