ResultExtensionsOkIf(Boolean, String) Method

Creates a result as Ok variant if the okCondition holds. Otherwise, it will map into an Err.
C#
static Res ValidateInput(Form form)
{
    return OkIf(!form.HasEmptyFields())
        .OkIf(form.Date <= DateTime.Now)
        // chained validation calls
        .OkIf(repo.AlreadyContains(form.Id));
}

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public static Res OkIf(
	bool okCondition,
	string strOkCondition = ""
)

Parameters

okCondition  Boolean
Condition that must hold for the return value to be Ok().
strOkCondition  String  (Optional)
Name of the condition; to be appended to the error message if it does not hold. Omitting the argument will automatically be filled with the condition's expression in the caller side.

Return Value

Res

See Also