Provides a DSL for booleans.
Provides a DSL for collection-like objects.
Wraps expressions under validation with a specialized scope (this is later used during the macro transform).
Wraps expression under validation with an explicit description; after macro transformation, the resulting validator will use the specified description to render violations.
Provides a DSL for untyped validators.
A structural type representing any object that has a size.
A structural type representing any object that has a size.
Provides a DSL for objects implementing scala.math.Ordering.
Provides a DSL for string validators.
Extends validators with useful helpers.
Generates a validator that succeeds only if the provided value is less than the specified bound.
Generates a validator that succeeds only if the provided value is less than the specified bound.
Generates a validator that succeeds if the provided value is less than or equal to the specified bound.
Generates a validator that succeeds if the provided value is less than or equal to the specified bound.
Generates a validator that succeeds if the provided value is exactly equal to the specified value.
Generates a validator that succeeds if the provided value is exactly equal to the specified value.
Generates a validator that succeeds only if the provided value is greater than the specified bound.
Generates a validator that succeeds only if the provided value is greater than the specified bound.
Generates a validator that succeeds if the provided value is greater than or equal to the specified bound.
Generates a validator that succeeds if the provided value is greater than or equal to the specified bound.
Specifies a validator that succeeds only if the validation expression is null.
Specifies a validator that succeeds only if the validation expression is null.
A proxy for ordering ops.
A proxy for ordering ops. Enables syntax such as p.age should be > 5
.
Generates a validator that succeeds if the provided value is between (inclusive) the specified bounds.
Generates a validator that succeeds if the provided value is between (inclusive) the specified bounds.
The method exclusive
is provided to specify an exclusive upper bound.
An implicit conversion from boolean to a respective IsTrue
/IsFalse
instance; this enables syntax
such as customer.emailOptIn is true
.
An implicit conversion from boolean to a respective IsTrue
/IsFalse
instance; this enables syntax
such as customer.emailOptIn is true
.
Specifies a validator that succeeds on empty instances; the object under validation must implement
def isEmpty: Boolean
(see com.wix.accord.combinators.HasEmpty).
Specifies a validator that succeeds on empty instances; the object under validation must implement
def isEmpty: Boolean
(see com.wix.accord.combinators.HasEmpty).
Specifies a validator that operates on strings and succeeds only if the validation expression ends with the specified suffix.
Specifies a validator that operates on strings and succeeds only if the validation expression ends with the specified suffix.
Specifies a validator that succeeds only if the validation expression is equal to the specified value.
Specifies a validator that succeeds only if the validation expression is equal to the specified value. Respects nulls an performs equality checks via java.lang.Object.equals.
An implicit conversion to enable any collection-like object (e.
An implicit conversion to enable any collection-like object (e.g. strings, options) to be handled by com.wix.accord.dsl.SizeContext.
java.lang.String does not directly implement size
(in practice it is implemented in
scala.collection.IndexedSeqOptimized via an implicit conversion and an inheritance stack), and this is
a case where the Scala compiler does not always infer structural types correctly. By requiring
a view bound from T
to scala.collection.GenTraversableOnce we can force any collection-like structure
to conform to the structural type com.wix.accord.dsl.CollectionOps.HasSize, and by requiring
a view bound from T
to com.wix.accord.dsl.CollectionOps.HasSize at the call site (via
com.wix.accord.dsl.SizeContext) we additionally support any class that directly
conforms to the structural type as well.
The type that conforms, directly or implicitly, to com.wix.accord.dsl.CollectionOps.HasSize.
An object that is, or is implicitly convertible to, scala.collection.GenTraversableOnce.
The specified object, strictly-typed as com.wix.accord.dsl.CollectionOps.HasSize.
Specifies a validator that operates on strings and succeeds only if the validation expression matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression **fully** matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression **fully** matches the specified regular expression. See com.wix.accord.combinators.StringCombinators.MatchesRegex for a full explanation of the difference between partial and full matching.
Specifies a validator that operates on strings and succeeds only if the validation expression **fully** matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression **fully** matches the specified regular expression. See com.wix.accord.combinators.StringCombinators.MatchesRegex for a full explanation of the difference between partial and full matching.
Specifies a validator that operates on strings and succeeds only if the validation expression **fully** matches the specified regular expression.
Specifies a validator that operates on strings and succeeds only if the validation expression **fully** matches the specified regular expression. See com.wix.accord.combinators.StringCombinators.MatchesRegex for a full explanation of the difference between partial and full matching.
Specifies a validator that fails on empty instances; the object under validation must implement
def isEmpty: Boolean
(see com.wix.accord.combinators.HasEmpty).
Specifies a validator that fails on empty instances; the object under validation must implement
def isEmpty: Boolean
(see com.wix.accord.combinators.HasEmpty).
Specifies a validator that succeeds only if the validation expression is not equal to the specified value.
Specifies a validator that succeeds only if the validation expression is not equal to the specified value. Respects nulls an performs equality checks via java.lang.Object.equals.
Specifies a validator that succeeds only if the validation expression is not null.
Specifies a validator that succeeds only if the validation expression is not null.
Provides access to size-based validators (where the object under validation must implement
def size: Int
, see com.wix.accord.dsl.CollectionOps.HasSize).
Provides access to size-based validators (where the object under validation must implement
def size: Int
, see com.wix.accord.dsl.CollectionOps.HasSize). Enables syntax such as
c.students has size > 0
.
Specifies a validator that operates on strings and succeeds only if the validation expression starts with the specified prefix.
Specifies a validator that operates on strings and succeeds only if the validation expression starts with the specified prefix.
Delegates validation to a pre-defined validation rule, which is encoded as an implicit com.wix.accord.Validator in scope.
Delegates validation to a pre-defined validation rule, which is encoded as an implicit com.wix.accord.Validator in scope. Enables composition of validation rules, as in:
case class Address( address1: String, address2: String, city: String, ... )
case class Item( sku: String, count: Int, ... )
case class Shipment( items: Seq[ Item ], address: Location, ... )
implicit val addressValidator = validator[ Address ] { ... } implicit val itemValidator = validator[ Item ] { ... }
implicit val shipmentValidator = validator[ Shipment ] { shipment => shipment.address is valid // Implicitly uses addressValidator shipment.items.each is valid // Implicitly uses itemValidator }
Takes a code block and rewrites it into a validation chain (see description in com.wix.accord.dsl.
Takes a code block and rewrites it into a validation chain (see description in com.wix.accord.dsl.
The type under validation.
The validation code block; may contain any combination of validation statements.
The validation code block rewritten as a com.wix.accord.Validator for the specified type T
.
Generates a validator that succeeds if the provided value is within the specified range.
Generates a validator that succeeds if the provided value is within the specified range.
Generates a validator that succeeds if the provided value is within the specified range.
Generates a validator that succeeds if the provided value is within the specified range.
Provides a DSL for defining validation rules. For example:
import dsl._ // Import the validator DSL
case class Person( firstName: String, lastName: String ) case class Classroom( teacher: Person, students: Seq[ Person ] )
implicit val personValidator = validator[ Person ] { p => p.firstName is notEmpty p.lastName is notEmpty }
implicit val classValidator = validator[ Classroom ] { c => c.teacher is valid // Implicitly relies on personValidator! c.students.each is valid c.students have size > 0 }
These validators can later be executed via com.wix.accord.validate. A macro transforms each validation block into a chain of validation rules at compile-time, and annotates accesses to getters so that violation messages are automatically generated; for instance, the rule
p.firstName is notEmpty
will generate the violation message "firstName must not be empty" automatically.