object
validation(Validation)
Validation term predicates. Requires passing a validation term (constructed using the validation object predicates) as a parameter.
logtalk_load(validations(loader))static, context_switching_callsPublic predicates
is_valid/0
True if the validation term holds a valid value.
staticis_valid - zero_or_oneis_invalid/0
True if the validation term holds one or more errors.
staticis_invalid - zero_or_oneif_valid/1
Applies a closure when the validation term holds a valid value using the value as argument. Succeeds otherwise.
staticif_valid(Closure)if_valid(1)if_valid(+callable) - zero_or_moreif_invalid/1
Applies a closure when the validation term holds errors using the errors list as argument. Succeeds otherwise.
staticif_invalid(Closure)if_invalid(1)if_invalid(+callable) - zero_or_moreif_valid_or_else/2
Applies either ValidClosure or InvalidClosure depending on the validation term holding a value or errors.
staticif_valid_or_else(ValidClosure,InvalidClosure)if_valid_or_else(1,1)if_valid_or_else(+callable,+callable) - zero_or_morevalid/1
Returns the value hold by the validation term. Throws an error otherwise.
staticvalid(Value)valid(--term) - one_or_errorexistence_error(valid_value,Validation)invalid/1
Returns the errors hold by the validation term. Throws an error otherwise.
staticinvalid(Errors)invalid(--list) - one_or_errorexistence_error(validation_errors,Validation)filter/3
When the validation term holds a value and the value satisfies the closure, returns the same validation term. When the validation term holds a value that does not satisfy the closure, returns an invalid term with the given error. When the validation term holds errors, returns the same validation term.
staticfilter(Closure,Error,NewValidation)filter(1,*,*)filter(+callable,@term,--nonvar) - onemap/2
When the validation term holds a valid value and mapping a closure with the value and the new value as additional arguments succeeds, returns a new valid term. Otherwise returns the same validation term.
staticmap(Closure,NewValidation)map(2,*)map(+callable,--nonvar) - oneflat_map/2
When the validation term holds a valid value, applies a closure with the value and the new validation term as additional arguments. Returns the new validation term on success. When the validation term holds errors, short-circuits by returning the same validation term without calling the closure. This is the monadic escape hatch for dependent steps; use zip/3, sequence/2, or traverse/3 for error accumulation on independent steps.
staticflat_map(Closure,NewValidation)flat_map(2,*)flat_map(+callable,--nonvar) - onemap_or_else/3
When the validation term holds a value and mapping a closure with the value and the new value as additional arguments is successful, returns the new value. Otherwise returns the given default value.
staticmap_or_else(Closure,Default,Value)map_or_else(2,*,*)map_or_else(+callable,@term,--term) - onemap_catching/2
When the validation term holds a value, applies a closure to it. Returns a valid term with the new value if the closure succeeds. Returns an invalid term with the error if the closure throws an error. Returns an invalid term with the atom fail as error if the closure fails. When the validation term holds errors, returns the same validation term.
staticmap_catching(Closure,NewValidation)map_catching(2,*)map_catching(+callable,--nonvar) - onemap_invalid/2
When the validation term holds errors and mapping a closure with the errors list and the new errors list as additional arguments succeeds, returns a new invalid term. Otherwise returns the same validation term.
staticmap_invalid(Closure,NewValidation)map_invalid(2,*)map_invalid(+callable,--nonvar) - onemap_both/3
When the validation term holds a value and mapping ValidClosure with the value is successful, returns a valid term with the new value. When the validation term holds errors and mapping InvalidClosure with the errors list is successful, returns an invalid term with the new errors. Otherwise returns the same validation term.
staticmap_both(ValidClosure,InvalidClosure,NewValidation)map_both(2,2,*)map_both(+callable,+callable,--nonvar) - oneswap/1
Swaps the valid and invalid terms. If the validation term holds a value, returns an invalid term with a singleton list containing that value. If the validation term holds errors, returns a valid term with the errors list.
staticswap(NewValidation)swap(--nonvar) - oneor/2
Returns the same validation term if it holds a value. Otherwise calls closure to generate a new validation term. Fails if the validation term holds errors and calling the closure fails or throws an error.
staticor(NewValidation,Closure)or(*,1)or(--term,@callable) - zero_or_oneor_else/2
Returns the valid value if present or the default value otherwise.
staticor_else(Value,Default)or_else(--term,@term) - oneor_else_get/2
Returns the value hold by the validation term if valid. Otherwise applies a closure to compute the value. Throws an error when the validation term holds errors and a value cannot be computed.
staticor_else_get(Value,Closure)or_else_get(*,1)or_else_get(--term,+callable) - one_or_errorexistence_error(valid_value,Validation)or_else_call/2
Returns the value hold by the validation term if valid. Calls a goal deterministically otherwise.
staticor_else_call(Value,Goal)or_else_call(*,0)or_else_call(--term,+callable) - zero_or_oneor_else_fail/1
Returns the valid value if present. Fails otherwise.
staticor_else_fail(Value)or_else_fail(--term) - zero_or_oneor_else_throw/1
Returns the value hold by the validation term if valid. Throws the errors list hold by the validation term as an exception otherwise.
staticor_else_throw(Value)or_else_throw(--term) - one_or_erroror_else_throw/2
Returns the value hold by the validation term if valid. Throws the given error otherwise, ignoring any errors hold by the validation term.
staticor_else_throw(Value,Error)or_else_throw(--term,@nonvar) - one_or_errorzip/3
When both this validation and the other validation hold values and applying a closure with both values and the new value as additional arguments is successful, returns a valid term with the new value. When both hold errors, returns an invalid term with all errors accumulated. Otherwise returns the first invalid term.
staticzip(Closure,OtherValidation,NewValidation)zip(3,*,*)zip(+callable,+nonvar,--nonvar) - oneflatten/1
Flattens a nested validation term. When the validation term holds a value that is itself a validation term, returns the inner validation term. When the validation term holds a non-validation value, returns the same validation term. When the validation term holds errors, returns the same validation term.
staticflatten(NewValidation)flatten(--nonvar) - oneto_optional/1
Converts the validation term to an optional term. Returns a non-empty optional term holding the value if the validation term holds a value. Returns an empty optional term if the validation term holds errors.
staticto_optional(Optional)to_optional(--nonvar) - oneto_expected/1
Converts the validation term to an expected term. Returns an expected term holding the value if the validation term holds a value. Returns an expected term with the errors list as the unexpected error otherwise.
staticto_expected(Expected)to_expected(--nonvar) - oneProtected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)
See also