private static FSharpChoice <string, Errors> Mandatory(string s) { return(FSharpChoice.Validator <string>(x => !string.IsNullOrEmpty(x), "Mandatory field")(s)); //if (string.IsNullOrEmpty(s)) // return FSharpChoice.Error<string>("Mandatory field"); //return FSharpChoice.Ok(s); }
static FSharpChoice <T, Errors> NotEqual <T>(T value, T other, string err) { return(FSharpChoice.Validator <T>(v => !Equals(v, other), err)(value)); }
static FSharpChoice <T, Errors> NonNull <T>(T value, string err) where T : class { return(FSharpChoice.Validator <T>(x => x != null, err)(value)); }