ValidationError

org.llm4s.error.ValidationError
See theValidationError companion class

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply(field: String, reason: String): ValidationError

Creates an error for a single violated rule.

Creates an error for a single violated rule.

The message is Invalid <field>: <reason>, violations is List(reason), and context holds field and violations.

Value parameters

field

the name of the field that failed validation

reason

why the value was rejected

Attributes

Returns

the validation error

def apply(field: String, violations: List[String]): ValidationError

Creates an error for several violated rules.

Creates an error for several violated rules.

The message is Invalid <field>: followed by the violations joined with ", ", while context("violations") joins them with "; ". An empty list gives a message that ends after the colon and a context with no violations entry.

Value parameters

field

the name of the field that failed validation

violations

the rules that were violated, in the order given

Attributes

Returns

the validation error

def invalid(field: String, reason: String): ValidationError

Creates an error for a field whose value is not acceptable.

Creates an error for a field whose value is not acceptable.

The message is Field '<field>' is invalid: <reason> (it does not use the Invalid <field>: form) and violations is List(reason).

Value parameters

field

the name of the field that failed validation

reason

why the value was rejected

Attributes

Returns

the validation error

def required(field: String): ValidationError

Creates an error for a missing required field.

Creates an error for a missing required field.

The message is Field '<field>' is required (it does not use the Invalid <field>: form) and violations is List("required").

Value parameters

field

the name of the missing field

Attributes

Returns

the validation error

Example
val error = ValidationError.required("name")
error.message    // "Field 'name' is required"
error.violations // List("required")
def unapply(error: ValidationError): Option[(String, String, List[String])]

Unapply extractor for pattern matching

Unapply extractor for pattern matching

Attributes