class ScalaValidator extends ScalaExecutableValidator with Logging
- Alphabetic
- By Inheritance
- ScalaValidator
- Logging
- ScalaExecutableValidator
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def close(): Unit
Close resources.
- def debug(marker: Marker, message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def debug(message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def debug(marker: Marker, message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def debug(message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def debugResult[T](message: => String)(fn: => T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def error(marker: Marker, message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def error(message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def error(marker: Marker, message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def error(message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def errorResult[T](message: => String)(fn: => T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- val findConstraintValidators: (Class[_ <: Annotation]) => Set[ConstraintValidatorType]
Returns the set of Constraints which validate the given Annotation class.
Returns the set of Constraints which validate the given Annotation class.
For instance if the constraint type is
Class[com.twitter.util.validation.constraints.CountryCode], the returned set would contain an instance of theISO3166CountryCodeConstraintValidator.- returns
the set of supporting constraint validators for a given Annotation.
- Note
this method is memoized as it should only ever need to be calculated once for a given Class.
- def forExecutables: ScalaExecutableValidator
Returns the contract for validating parameters and return values of methods and constructors.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getConstraintsForClass[T](clazz: Class[T]): CaseClassDescriptor[T]
Returns a CaseClassDescriptor object describing the given case class type constraints.
Returns a CaseClassDescriptor object describing the given case class type constraints. Descriptors describe constraints on a given class and any cascaded case class types.
The returned object (and associated objects including CaseClassDescriptors) are immutable.
- T
the clazz type
- clazz
class or interface type evaluated
- returns
the CaseClassDescriptor for the specified class
- See also
CaseClassDescriptor
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def info(marker: Marker, message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def info(message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def info(marker: Marker, message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def info(message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def infoResult[T](message: => String)(fn: => T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isConstraintAnnotation(annotation: Annotation): Boolean
Checks whether the specified Annotation is a valid constraint constraint.
Checks whether the specified Annotation is a valid constraint constraint. A constraint constraint has to fulfill the following conditions:
- Must be annotated with jakarta.validation.Constraint
- Define a
messageparameter - Define a
groupsparameter - Define a
payloadparameter
- annotation
The Annotation to test.
- returns
true if the constraint fulfills the above conditions, false otherwise.
- val isConstraintAnnotation: (Class[_ <: Annotation]) => Boolean
Checks whether the specified Annotation clazz is a valid constraint constraint.
Checks whether the specified Annotation clazz is a valid constraint constraint. A constraint constraint has to fulfill the following conditions:
- Must be annotated with jakarta.validation.Constraint
- Define a
messageparameter - Define a
groupsparameter - Define a
payloadparameter
- returns
true if the constraint fulfills the above conditions, false otherwise.
- Note
this method is memoized as it should only ever need to be calculated once for a given Class.
- def isDebugEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isDebugEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isErrorEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isErrorEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isInfoEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isInfoEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTraceEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isTraceEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isWarnEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- def isWarnEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
- final def logger: Logger
- Attributes
- protected[this]
- Definition Classes
- Logging
- final def loggerName: String
- Attributes
- protected[this]
- Definition Classes
- Logging
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def trace(marker: Marker, message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def trace(message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def trace(marker: Marker, message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def trace(message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def traceResult[T](message: => String)(fn: => T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
- val underlying: Validator
- def unwrap[U](clazz: Class[U]): U
Returns an instance of the specified type allowing access to provider-specific APIs.
Returns an instance of the specified type allowing access to provider-specific APIs.
If the Jakarta Bean Validation provider implementation does not support the specified class, ValidationException is thrown.
- U
the type of the object to be returned
- clazz
the class of the object to be returned
- returns
an instance of the specified class
- Annotations
- @throws(scala.this.throws.<init>$default$1[jakarta.validation.ValidationException])
- Exceptions thrown
ValidationException- if the provider does not support the call.
- def validate[T](obj: T, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all constraint constraints on an object.
Validates all constraint constraints on an object.
- T
the type of the object to validate.
- obj
the object to validate.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
constraint violations or an empty set if none
- Exceptions thrown
IllegalArgumentException- if object is null.
- def validateConstructorParameters[T](constructor: Constructor[T], parameterValues: Array[Any], groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all constraints placed on the parameters of the given constructor.
Validates all constraints placed on the parameters of the given constructor.
- T
the type hosting the constructor to validate.
- constructor
the constructor for which the parameter constraints is validated.
- parameterValues
the values provided by the caller for the given constructor's parameters.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
a set with the constraint violations caused by this validation; Will be empty if no error occurs, but never null.
- Definition Classes
- ScalaValidator → ScalaExecutableValidator
- def validateConstructorReturnValue[T](constructor: Constructor[T], createdObject: T, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all return value constraints of the given constructor.
Validates all return value constraints of the given constructor.
- T
the type hosting the constructor to validate.
- constructor
the constructor for which the return value constraints is validated.
- createdObject
the object instantiated by the given method.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
a set with the constraint violations caused by this validation; will be empty, if no error occurs, but never null.
- Definition Classes
- ScalaValidator → ScalaExecutableValidator
- def validateMethod[T](obj: T, method: Method, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates the given method annotated with
@MethodValidationof the given object.Validates the given method annotated with
@MethodValidationof the given object.- T
the type hosting the method to validate.
- obj
the object on which the method to validate is invoked.
- method
the
@MethodValidationannotated method to invoke for validation.- groups
the list of groups targeted for validation (defaults to Default).
- returns
a set with the constraint violations caused by this validation; will be empty if no error occurs, but never null.
- Definition Classes
- ScalaValidator → ScalaExecutableValidator
- def validateMethodParameters[T](method: Method, parameterValues: Array[Any], groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all constraints placed on the parameters of the given method.
Validates all constraints placed on the parameters of the given method.
- T
the type defining the method to validate.
- method
the method for which the parameter constraints is validated.
- parameterValues
the values provided by the caller for the given method's parameters.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
a set with the constraint violations caused by this validation; Will be empty if no error occurs, but never null.
- Definition Classes
- ScalaValidator → ScalaExecutableValidator
- def validateMethods[T](obj: T, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all methods annotated with
@MethodValidationof the given object.Validates all methods annotated with
@MethodValidationof the given object.- T
the type hosting the methods to validate.
- obj
the object on which the methods to validate are invoked.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
a set with the constraint violations caused by this validation; will be empty if no error occurs, but never null.
- Definition Classes
- ScalaValidator → ScalaExecutableValidator
- def validateParameters[T](obj: T, method: Method, parameterValues: Array[Any], groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all constraints placed on the parameters of the given method.
Validates all constraints placed on the parameters of the given method.
- T
the type hosting the method to validate.
- obj
the object on which the method to validate is invoked.
- method
the method for which the parameter constraints is validated.
- parameterValues
the values provided by the caller for the given method's parameters.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
a set with the constraint violations caused by this validation; will be empty if no error occurs, but never null.
- Definition Classes
- ScalaValidator → ScalaExecutableValidator
- def validateProperty[T](obj: T, propertyName: String, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all constraint constraints on the
fieldNamefield of the given object.Validates all constraint constraints on the
fieldNamefield of the given object.Usage
Validate the "id" field in case class
MyClass(enabling the validation group "Checks"):case class MyClass(@NotEmpty(groups = classOf[Checks]) id) val i = MyClass("") validator.validateProperty(i, "id", Seq(classOf[Checks]))
- T
the type of the object to validate.
- obj
object to validate.
- propertyName
property to validate (used in error reporting).
- groups
the list of groups targeted for validation (defaults to Default).
- returns
constraint violations or an empty set if none.
- Exceptions thrown
IllegalArgumentException- if object is null, if fieldName is null, empty or not a valid object property.
- def validateReturnValue[T](obj: T, method: Method, returnValue: Any, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all return value constraints of the given method.
Validates all return value constraints of the given method.
- T
the type hosting the method to validate.
- obj
the object on which the method to validate is invoked.
- method
the method for which the return value constraints is validated.
- returnValue
the value returned by the given method.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
a set with the constraint violations caused by this validation; will be empty if no error occurs, but never null.
- Definition Classes
- ScalaValidator → ScalaExecutableValidator
- def validateValue[T](descriptor: CaseClassDescriptor[T], propertyName: String, value: Any, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all constraint constraints on the
fieldNamefield of the class described by the given CaseClassDescriptor if thefieldNamefield value werevalue.Validates all constraint constraints on the
fieldNamefield of the class described by the given CaseClassDescriptor if thefieldNamefield value werevalue.- T
the type of the object to validate
- descriptor
the CaseClassDescriptor of the described class.
- propertyName
field to validate.
- value
field value to validate.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
constraint violations or an empty set if none
- Exceptions thrown
IllegalArgumentException- if fieldName is null, empty or not a valid object property.
- def validateValue[T](beanType: Class[T], propertyName: String, value: Any, groups: Class[_]*): Set[ConstraintViolation[T]]
Validates all constraint constraints on the
fieldNamefield of the given classbeanTypeif thefieldNamefield value werevalue.Validates all constraint constraints on the
fieldNamefield of the given classbeanTypeif thefieldNamefield value werevalue.ConstraintViolation objects return
nullfor ConstraintViolation.getRootBean() and ConstraintViolation.getLeafBean().Usage
Validate value of "" for the "id" field in case class
MyClass(enabling group "Checks"):case class MyCaseClass(@NotEmpty(groups = classOf[Checks]) id) validator.validateFieldValue(classOf[MyCaseClass], "id", "", Seq(classOf[Checks]))
- T
the type of the object to validate
- beanType
the case class type.
- propertyName
field to validate.
- value
field value to validate.
- groups
the list of groups targeted for validation (defaults to Default).
- returns
constraint violations or an empty set if none
- Exceptions thrown
IllegalArgumentException- if beanType is null, if fieldName is null, empty or not a valid object property.
- def verify(obj: Any, groups: Class[_]*): Unit
Validates all constraint constraints on an object.
Validates all constraint constraints on an object.
- obj
the object to validate.
- Annotations
- @throws(scala.this.throws.<init>$default$1[jakarta.validation.ValidationException])
- Exceptions thrown
IllegalArgumentException- if object is null.ValidationException- if any constraints produce a violation.
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def warn(marker: Marker, message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def warn(message: => Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def warn(marker: Marker, message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def warn(message: => Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
- def warnResult[T](message: => String)(fn: => T): T
- Attributes
- protected[this]
- Definition Classes
- Logging