OptTSomeIf Method
Returns back None if IsNone.
Otherwise, returns Some(value) if
validationCriterion(value) holds; None if it does not hold.
Especially useful in fluent input validation.
static Opt<Account> MaybeParseAccount(..) { }
static bool IsAccountNumberValid(int number) { }
static bool DoesAccountExist(string code) { }
var account = MaybeParseAccount(..)
.Validate(acc => IsAccountNumberValid(acc.Number))
.Validate(acc => DoesAccountExist(acc.Code));
// account will be Some(account) only if:
// - MaybeParseAccount returns Some(account), and further,
// - both IsAccountNumberValid and DoesAccountExist validation checks return true.
Namespace: Orx.Fun.OptionAssembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
public Opt<T> SomeIf(
Func<T, bool> validationCriterion
)
- validationCriterion FuncT, Boolean
- Condition on the underlying value that should hold to get a Some, rather than None.
OptT