Ejemplo n.º 1
0
        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>(() => { }));
            }
        }