コード例 #1
0
        public void Validate(ContactModel obj, AuthServer.Common.Validation.IValidator validator, string prefix = "")
        {
            var fvResult = _rules.Validate(obj);

            if (!fvResult.IsValid)
            {
                foreach (var err in fvResult.Errors)
                {
                    validator.AddError(err.ErrorMessage, prefix + err.PropertyName);
                }
            }
        }
コード例 #2
0
        public void Validate(CreateUserModel userModel, AuthServer.Common.Validation.IValidator validator, string prefix = "")
        {
            var fvResult = _rules.Validate(userModel);

            if (!fvResult.IsValid)
            {
                foreach (var err in fvResult.Errors)
                {
                    validator.AddError(err.ErrorMessage, prefix + err.PropertyName);
                }
            }

            if (userModel.Contacts != null)
            {
                for (int i = 0; i < userModel.Contacts.Count;)
                {
                    _newContactValidationStrategy.Validate(userModel.Contacts[i], validator, $"{prefix}.{i++}");
                }
            }
        }