Beispiel #1
0
        public ILeoValidationContext ForMember(string name, Func <ILeoValueRuleBuilder, ILeoValueRuleBuilder> func)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            var handler = _visitor.ExposeLazyMemberHandler().Value;
            var builder = new CorrectValueRuleBuilder(handler.GetMember(name), () => handler.GetInstanceObject(), () => handler.GetValueObject(name));
            var rule    = ((CorrectValueRuleBuilder)func(builder)).Build();

            AddOrUpdateValueRule(rule);
            return(this);
        }
        public virtual VerifyResult VerifyOne(string memberName, bool withGlobalRules, string withGlobalProviderName = "")
        {
            if (ValidationHandler is null)
            {
                return(VerifyResult.Success);
            }
            var value  = _visitor.ExposeLazyMemberHandler().Value.GetValueObject(memberName);
            var master = ValidationHandler.VerifyOne(_visitor.SourceType, value, memberName);
            var slave  = withGlobalRules
                ? ValidationMe.Resolve(_visitor.SourceType, withGlobalProviderName).Verify(_visitor.SourceType, _visitor.Instance)
                : VerifyResult.Success;

            return(VerifyResult.Merge(master, slave));
        }