StringRule

Functions

Link copied to clipboard

Validate that the element consists only of letters.

Link copied to clipboard

Validate that the element consists only of letters or numbers.

Link copied to clipboard
fun <R : ValidationRule<String>> R.either(vararg option: String): R

Validate that the element should be equal to one of the elements in option given that it is set.

Link copied to clipboard
fun endsWith(suffix: String, ignoreCase: Boolean = false): StringRule

Validate that the element ends with a given suffix.

Link copied to clipboard
fun <R : ValidationRule<String>> R.exactly(value: String): R

Validate that the element should be equal to value given that it is set.

Link copied to clipboard
fun <R : ValidationRule<String>> R.given(precondition: (String?) -> Boolean, rule: R.() -> R): R

Validate rule only if precondition evaluates to true.

Link copied to clipboard
fun <R : ValidationRule<String>> R.holds(message: (String?) -> String = { "Was supposed to hold for '$it' but did not" }, predicate: (String?) -> Boolean): R

Validate that predicate evaluates to true.

Link copied to clipboard

Validate that the element is kebab case.

Link copied to clipboard

Validate that the element is lowercase.

Link copied to clipboard
fun matches(regex: Regex): StringRule

Validate that the element matches regex.

Link copied to clipboard
fun <R : ValidationRule<String>> R.not(message: String, rule: R.() -> R): R

Validate that the rule does not hold.

Link copied to clipboard

Validate that the element consists only of numbers.

Link copied to clipboard
fun <V, R : ValidationRule<String>> R.optional(value: (String?) -> V?, rule: R.() -> R): R

Validate rule only if the evaluated result of value is not null.

Link copied to clipboard

Validate that the element is set.

Link copied to clipboard
fun <R : ValidationRule<String>> R.since(date: LocalDate, rule: R.() -> R): R

Validate rule only if date has been in the past.

Link copied to clipboard

Validate that the element is snake case.

Link copied to clipboard
fun startsWith(prefix: String, ignoreCase: Boolean = false): StringRule

Validate that the element starts with a given prefix.

Link copied to clipboard

Validate that the element is not set.

Link copied to clipboard

Validate that the element is uppercase.

Link copied to clipboard

Execute the given rule(s) on the fixture.