예제 #1
0
    protected override ValidationResult?IsValid(object?value, ValidationContext validationContext)
    {
        var spaceSeparatedExpressions = value?.ToString();

        if (string.IsNullOrWhiteSpace(spaceSeparatedExpressions))
        {
            return(ValidationResult.Success);
        }

        var expressions = spaceSeparatedExpressions.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

        foreach (var expression in expressions)
        {
            if (!GlobExpression.IsValid(expression))
            {
                return(new ValidationResult("Invalid expression."));
            }
        }

        return(ValidationResult.Success);
    }
예제 #2
0
 public void IsValid(string expression, bool isPositive)
 {
     GlobExpression.IsValid(expression).Should().Be(isPositive);
 }