Package-level declarations

Properties

Link copied to clipboard

Whether this is Input.Empty

Link copied to clipboard

Whether the actual string of this Input is blank

Link copied to clipboard

Whether this is Input.Invalid

Link copied to clipboard

Whether this is Input.Valid

Link copied to clipboard

Whether this Input is valid or empty

Functions

Link copied to clipboard
@JvmName(name = "checksAll")
infix inline fun () -> Boolean.checks(crossinline error: () -> Iterable<ValidationError>): Sequence<ValidationError>
infix inline fun () -> Boolean.checks(crossinline error: () -> ValidationError): Sequence<ValidationError>

A function that evaluates this lambda, and if it returns false, returns the result of error wrapped in a sequence. Shorthand for an if statement and a sequence build

Link copied to clipboard
fun empty(default: String? = null): Input.Empty
Link copied to clipboard

Create an Input.Empty from this string as a default.

Link copied to clipboard

Fold this list of ValidationErrors to an Input value. Use after running validation on a string.

Transform these ValidationErrors into an Input value based on whether there are any errors If no errors, returns Input.Valid or Input.Empty

Link copied to clipboard
fun input(value: String? = null): Input
Link copied to clipboard
@JvmName(name = "inputString")
fun String?.input(): Input

Creates a new Input from this string. Whether this will be an Input.Empty or Input.Valid depends on whether the value is a blank string.

Link copied to clipboard
operator fun Array<out Rule>.invoke(input: String, strategy: ValidationStrategy): List<ValidationError>

operator fun Sequence<Rule>.invoke(input: String, strategy: ValidationStrategy): List<ValidationError>

Runs all validations on a given sequence of rules.

Link copied to clipboard

Returns a new Rule instantiated lazily for a given check.

Link copied to clipboard
infix fun Input.mustMatch(other: Input): Input

Applies an additional Rules.Equals to this input, then appends the result of the validation to other validation errors present, if any. Allows to create an Input that must always match some other one Don't forget to run the validation on both the dependent and the original inputs when any of them changes.

Link copied to clipboard

Returns Input.value if it is valid, otherwise an empty string

Link copied to clipboard

Returns Input.value if it is valid, otherwise null

Link copied to clipboard
fun String?.validate(form: Form): Input

Validates this String using a given Form

fun String?.validate(rule: Rule): Input

Validates this String using a given Rule

fun Input.validate(form: Form): Input

Validate this Input using a given form.

fun Input.validate(rule: Rule): Input

Validate this Input using the given rule. Previous errors are preserved.

Link copied to clipboard
infix fun Form.validates(value: String): Input

Infix fun syntax shorthand for validateWith.

Link copied to clipboard
infix fun String?.validateWith(form: Form): Input

Validate this string with the given form.

Link copied to clipboard

Returns null if this Input is not valid, otherwise returns Input.value