public ValidatorBuilder <object> CreateValidatorBuilder() { var builder = new ValidatorBuilder <object>(); builder.AddKnownType <TestClass>(); builder.AddRegexAttributeConstraint <RegexAttribute>(a => a.Pattern); return(builder); }
public static void AddEmptyConstraint <TState>(this ValidatorBuilder <TState> builder, bool withType = false) { if (withType) { builder.AddKnownType <SimpleWithConstraint>(); builder.AddConstraint(p => { if (p == typeof(SimpleWithConstraint).GetProperty(nameof(SimpleWithConstraint.Test))) { return(new DelegateConstraint <TState>(() => { })); } return(null); }); } else { builder.AddConstraint(_ => new DelegateConstraint <TState>(() => { })); } }
public static void AddEmptyClass <TState>(this ValidatorBuilder <TState> builder) { builder.AddKnownType <SimpleWithConstraint>(); }