Validator

sttp.tapir.Validator$
See theValidator companion trait
object Validator extends ValidatorMacros

Attributes

Companion:
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Type members

Classlikes

case class All[T](validators: Seq[Validator[T]]) extends Validator[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Validator[T]
class Object
trait Matchable
class Any
case class Any[T](validators: Seq[Validator[T]]) extends Validator[T]

Attributes

Companion:
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Validator[T]
class Object
trait Matchable
class Any
object Any

Attributes

Companion:
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Any.type
case class Custom[T](validationLogic: T => ValidationResult, showMessage: Option[String]) extends Primitive[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[T]
trait Validator[T]
class Object
trait Matchable
class Any
case class Enumeration[T](possibleValues: List[T], encode: Option[() => T], name: Option[SName]) extends Primitive[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[T]
trait Validator[T]
class Object
trait Matchable
class Any
case class Mapped[TT, T](wrapped: Validator[T], g: TT => T) extends Validator[TT]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Validator[TT]
class Object
trait Matchable
class Any
case class Max[T](value: T, exclusive: Boolean)(implicit valueIsNumeric: Numeric[T]) extends Primitive[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[T]
trait Validator[T]
class Object
trait Matchable
class Any
case class MaxLength[T <: String](value: Int) extends Primitive[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[T]
trait Validator[T]
class Object
trait Matchable
class Any
case class MaxSize[T, C <: (Iterable)](value: Int) extends Primitive[C[T]]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[C[T]]
trait Validator[C[T]]
class Object
trait Matchable
class Any
case class Min[T](value: T, exclusive: Boolean)(implicit valueIsNumeric: Numeric[T]) extends Primitive[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[T]
trait Validator[T]
class Object
trait Matchable
class Any
case class MinLength[T <: String](value: Int) extends Primitive[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[T]
trait Validator[T]
class Object
trait Matchable
class Any
case class MinSize[T, C <: (Iterable)](value: Int) extends Primitive[C[T]]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[C[T]]
trait Validator[C[T]]
class Object
trait Matchable
class Any
case class Pattern[T <: String](value: String) extends Primitive[T]

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Primitive[T]
trait Validator[T]
class Object
trait Matchable
class Any
sealed trait Primitive[T] extends Validator[T]

Attributes

Graph
Supertypes
trait Validator[T]
class Object
trait Matchable
class Any
Known subtypes
class Custom[T]
class Enumeration[T]
class Max[T]
class MaxLength[T]
class MaxSize[T, C]
class Min[T]
class MinLength[T]
class MinSize[T, C]
class Pattern[T]

Types

type EncodeToRaw[T] = T => Option[Any]

Value members

Concrete methods

def all[T](v: Validator[T]*): Validator[T]
def any[T](v: Validator[T]*): Validator[T]
def custom[T](validationLogic: T => ValidationResult, showMessage: Option[String]): Validator[T]

Create a custom validator.

Create a custom validator.

Attributes

showMessage

Description of the validator used when invoking Validator.show.

validationLogic

The logic of the validator

def enumeration[T](possibleValues: List[T]): Enumeration[T]

Create an enumeration validator, with the given possible values.

Create an enumeration validator, with the given possible values.

To represent the enumerated values in documentation, an encoding function needs to be provided. This can be done:

  • by using the overloaded enumeration method with an encode parameter
  • by adding an encode function on an Validator.Enumeration instance using one of the .encode functions
  • by adding the validator directly to a codec (see Mapping.addEncodeToEnumValidator)
  • when the values possible values are of a basic type (numbers, strings), the encode function is inferred if not present, when being added to the schema, see Schema.validate

Attributes

def enumeration[T](possibleValues: List[T], encode: () => T, name: Option[SName]): Enumeration[T]

Create an enumeration validator, with the given possible values, an optional encoding function (so that the enumerated values can be represented in documentation), and an optional name (to create a reusable documentation component).

Create an enumeration validator, with the given possible values, an optional encoding function (so that the enumerated values can be represented in documentation), and an optional name (to create a reusable documentation component).

Attributes

encode

Specify how values of this type can be encoded to a raw value, which will be used for documentation.

def fixedLength[T <: String](value: Int): Validator[T]
def fixedSize[T, C <: (Iterable)](value: Int): Validator[C[T]]
def inRange[T : Numeric](min: T, max: T, minExclusive: Boolean, maxExclusive: Boolean): Validator[T]
def max[T : Numeric](value: T, exclusive: Boolean): Primitive[T]
def maxLength[T <: String](value: Int): Primitive[T]
def maxSize[T, C <: (Iterable)](value: Int): Primitive[C[T]]
def min[T : Numeric](value: T, exclusive: Boolean): Primitive[T]
def minLength[T <: String](value: Int): Primitive[T]
def minSize[T, C <: (Iterable)](value: Int): Primitive[C[T]]
def negative[T : Numeric]: Primitive[T]
def nonEmpty[T, C <: (Iterable)]: Primitive[C[T]]
def nonEmptyString[T <: String]: Primitive[T]
def pass[T]: Validator[T]

A validator instance that always pass.

A validator instance that always pass.

Attributes

def pattern[T <: String](value: String): Primitive[T]
def positive[T : Numeric]: Primitive[T]
def positiveOrZero[T : Numeric]: Primitive[T]
def reject[T]: Validator[T]

A validator instance that always reject.

A validator instance that always reject.

Attributes

def show[T](v: Validator[T]): Option[String]

Inherited methods

Creates an enum validator for an enum where all cases are parameterless, or where all subtypes of the sealed hierarchy T are objects. This enumeration will only be used for documentation, as a value outside of the allowed values will not be decoded in the first place (the decoder has no other option than to fail).

Creates an enum validator for an enum where all cases are parameterless, or where all subtypes of the sealed hierarchy T are objects. This enumeration will only be used for documentation, as a value outside of the allowed values will not be decoded in the first place (the decoder has no other option than to fail).

Attributes

Inherited from:
ValidatorMacros