コード例 #1
0
ファイル: Validate.cs プロジェクト: jableader/cshite
 /// <summary>
 /// For a simple yes/no question where 'y' is true
 /// </summary>
 public static Validator <bool> Bool()
 {
     return(response => Regex.IsMatch(response, "^(y|n|yes|no)$", RegexOptions.IgnoreCase) ?
            Validated <bool> .Success(response.StartsWith("y", StringComparison.OrdinalIgnoreCase)) :
            Validated <bool> .Error("Please enter 'y' or 'n'."));
 }