Package-level declarations

Pre-defined schema validations for different data types.

Pre-defined schema validations for different data types.

Types

Link copied to clipboard
open class Accepts @JvmOverloads constructor(acceptedFileTypes: Iterable<String>, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<File>

Validation that checks that a file's type is one of the acceptedFileTypes.

Link copied to clipboard
open class ExclusiveMax<T : Comparable<T>> @JvmOverloads constructor(val exclusiveMax: T, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value is less than a given exclusiveMax value.

Link copied to clipboard
open class ExclusiveMin<T : Comparable<T>> @JvmOverloads constructor(val exclusiveMin: T, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value is greater than a given exclusiveMin value.

Link copied to clipboard
open class Length @JvmOverloads constructor(val requiredLength: Int, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<CharSequence>

Validation that checks that a string's length is exactly requiredLength, when it is not empty.

Link copied to clipboard
open class Matches @JvmOverloads constructor(val regex: Regex, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<String>

Validation that checks that a string matches a given regex, when it is not empty.

Link copied to clipboard

Validation that checks that a form value matches a given computedValue.

Link copied to clipboard
open class MatchesEmail @JvmOverloads constructor(val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error, val regex: Regex = EMAIL_REGEX) : Matches

Validation that checks that a string matches an email according to regex (which defaults to EMAIL_REGEX) when it is not empty.

Link copied to clipboard
open class Max<T : Comparable<T>> @JvmOverloads constructor(val max: T, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value is at most a given max value.

Link copied to clipboard
open class MaxLength @JvmOverloads constructor(val maxLength: Int, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<CharSequence>

Validation that checks that a string's length is at most a given maxLength.

Link copied to clipboard
open class MaxSize @JvmOverloads constructor(val maxSize: Int, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<Any>

Validation that checks that a value's size is at most a given maxSize. Values of type Collection, Array (including variants), Map, Table, and File are supported.

Link copied to clipboard
open class Min<T : Comparable<T>> @JvmOverloads constructor(val min: T, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value is at least a given min value.

Link copied to clipboard
open class MinLength @JvmOverloads constructor(val minLength: Int, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<CharSequence>

Validation that checks that a string's length is at least a given minLength, when it is not empty.

Link copied to clipboard
open class MinSize @JvmOverloads constructor(val minSize: Int, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<Any>

Validation that checks that a value's size is at least a given minSize, when it is not empty. Values of type Collection, Array (including variants), Map, Table, and File are supported.

Link copied to clipboard
open class MustEqual<T> @JvmOverloads constructor(val requiredValue: T, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value equals a given requiredValue.

Link copied to clipboard
open class MustNotEqual<T> @JvmOverloads constructor(val forbiddenValue: T, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value does not equal a given forbiddenValue.

Link copied to clipboard
open class NotBlank @JvmOverloads constructor(val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<CharSequence>

Validation that checks that a string is not blank (according to String.isBlank) when it is also not empty.

Link copied to clipboard
open class NotEmpty @JvmOverloads constructor(val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<Any>

Validation that checks that a value is not empty. Values of type String, Collection, Array (and variants), Map, Table, and File are supported.

Link copied to clipboard
open class NotOneOf<T> @JvmOverloads constructor(disallowedValues: Iterable<T>, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value is not one of the disallowedValues.

Link copied to clipboard
open class OneOf<T> @JvmOverloads constructor(allowedValues: Iterable<T>, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<T>

Validation that checks that a value is one of the allowedValues.

Link copied to clipboard
open class Required @JvmOverloads constructor(val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<Any?>

Validation that checks that a value is not missing (this checks that the value is not null, false, or empty). This validation checks the emptiness of values of type String, Collection, Array (and variants), Map, and Table.

Link copied to clipboard
open class Scale @JvmOverloads constructor(val requiredScale: Int, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<BigDecimal>

Validation that checks that a big decimal value's scale is requiredScale.

Link copied to clipboard
abstract class ScopedAsyncValidation<in T, TScope> @JvmOverloads constructor(scopeExternalContextName: String = DEFAULT_SCOPE_EXTERNAL_CONTEXT_NAME) : ScopedJvmValidation<T, TScope>

Asynchronous scoped validation more easily implementable from Java.

Link copied to clipboard
abstract class ScopedJvmValidation<in T, TScope> @JvmOverloads constructor(scopeExternalContextName: String = DEFAULT_SCOPE_EXTERNAL_CONTEXT_NAME) : ScopedValidation<T, TScope>

ScopedValidation more easily implementable from Java.

Link copied to clipboard
abstract class ScopedStatefulValidation<in T, TState, TScope> @JvmOverloads constructor(scopeExternalContextName: String = ScopedValidation.DEFAULT_SCOPE_EXTERNAL_CONTEXT_NAME) : StatefulValidation<T, TState>

A scoped stateful validation is a stateful validation that should only run when the current "validation scope" is allowed by the provided scopes.

Link copied to clipboard
abstract class ScopedSyncValidation<in T, TScope> @JvmOverloads constructor(scopeExternalContextName: String = DEFAULT_SCOPE_EXTERNAL_CONTEXT_NAME) : ScopedJvmValidation<T, TScope>

Synchronous scoped validation more easily implementable from Java.

Link copied to clipboard
abstract class ScopedValidation<in T, TScope> @JvmOverloads constructor(scopeExternalContextName: String = DEFAULT_SCOPE_EXTERNAL_CONTEXT_NAME) : Validation<T>

A scoped validation is a validation that should only run when the current "validation scope" is allowed by the provided scopes.

Link copied to clipboard
open class Size @JvmOverloads constructor(val requiredSize: Int, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : Validation<Any>

Validation that checks that a value's size is exactly requiredSize, when it is not empty. Values of type Collection, Array (including variants), Map, Table, and File are supported.

Link copied to clipboard
open class UniqueItems @JvmOverloads constructor(emitAllRepetitions: Boolean = true, val treatNullAsUnique: Boolean = true, code: String = DEFAULT_CODE, severity: ValidationIssueSeverity = ValidationIssueSeverity.Error) : UniqueItemsBy<Any?, Any?>

Validation that ensures that a value does not contain repeated items. Values of type Collection, Array (including variants), and Table are supported.

Link copied to clipboard
open class UniqueItemsBy<T, TKey> @JvmOverloads constructor(val emitAllRepetitions: Boolean = true, val code: String = DEFAULT_CODE, val severity: ValidationIssueSeverity = ValidationIssueSeverity.Error, val selector: (item: T) -> TKey?) : Validation<Any>

Validation that ensures that a value does not contain repeated items, where the uniqueness of an item is determined by its key as returned by selector. Values of type Collection, Array (including variants), and Table are supported.

Link copied to clipboard
sealed class ValidationScopes<T> : Set<T?>

Validation scopes under which a validation is allowed to run. These can be specified via an allow list with OneOf or via a deny list with NotOneOf.

Functions

Link copied to clipboard

Returns whether a value is missing (this checks whether the value is null, false, or empty). The emptiness of values of type String, Collection, Array (and variants), Map, and Table is checked.

Link copied to clipboard

Returns whether a value is not missing (this checks that the value is not null, false, or empty). The emptiness of values of type String, Collection, Array (and variants), Map, and Table is checked.