notNull

Validates that the optional value is not null.

This function creates a validation rule that checks if a nullable value is not null. The null check is applied immediately when this function is called, making the then call optional. It returns a ValidationRuleChainer that allows you to chain additional validation rules using the then infix function. The chained rules will only be applied if the value is not null.

Usage:

// Basic null check only
rules<String?> {
notNull { "Value is required" }
}

// Null check with additional validation
rules<String?> {
notNull { "Value is required" } then {
notBlank { "Value cannot be blank" }
minLength(3) { "Value must be at least 3 characters" }
}
}

Return

An ValidationRuleChainer that allows chaining additional validation rules.

Parameters

V

The non-nullable type of the value being validated.

message

A function that returns the error message when the value is null.