Exemple #1
0
        protected override bool EvaluateIsValid()
        {
            //UPDATE: Because the SpecificationManager is a Custom Validator, it will only be run on the server
            //          If SpecExpress Web is used in conjunction with a standard ASP.NET Validator, and a Validator fails,
            //          SpecificationManager will not execute, so each Validator will need to continue to support validating a property
            if (ValidationNotification == null)
            {
                //Validate just this property
                //Create a new object of Type and set the property
                PropertyErrors = validateProperty();
            }

            //TODO: Also check in Nested ValidationResults for this PropertyType and PropertyName
            if (PropertyErrors.Any())
            {
                //Update error message to change Property Name to label
                var pageLocalizedPropertyErrors = PropertyErrors.Select(x => x.Message.Replace(x.Property.Name.SplitPascalCase(), GetLabelName())).ToList();
                ErrorMessage = FormatErrorMessage(pageLocalizedPropertyErrors, DisplayMode);
                IsValid      = false;
                return(false);
            }
            else
            {
                IsValid = true;
                return(true);
            }
        }
 protected PropertyErrorsException(
     SerializationInfo info,
     StreamingContext context)
     : base(info, context)
 {
     this._propertyErrors = (PropertyErrors)info.GetValue("_propertyErrors", typeof(PropertyErrors));
 }
 public void AddError(string property, string message)
 {
     if (string.IsNullOrWhiteSpace(property))
     {
         ModelErrors.Add(new SimpleError {
             Key = property, ErrorMessage = message
         });
     }
     else
     {
         PropertyErrors.Add(new SimpleError {
             Key = property, ErrorMessage = message
         });
     }
 }
Exemple #4
0
            public PropertyValidator(IPropertyErrorsContainerInternal <T> container, IProperty <TProperty> property, Func <T, TProperty, string> validateFunc)
            {
                Container              = container;
                _validateFunc          = validateFunc;
                Property               = property;
                property.ValueChanged += HandlePropertyValueChanged;

                PropertyErrors = new PropertyErrors(property.NameArgs.PropertyName);
                Container.AddValidator(this);

                _cleanup = new ActionDisposable(() =>
                {
                    Container.RemoveValidator(this);
                    property.ValueChanged -= HandlePropertyValueChanged;
                });
            }
 public PropertyErrorsException(PropertyError propertyError, Exception inner)
     : base("", inner)
 {
     _propertyErrors = new PropertyErrors();
     _propertyErrors.Add(propertyError);
 }
 public PropertyErrorsException(PropertyErrors propertyErrors, Exception inner)
     : base("", inner)
 {
     _propertyErrors = propertyErrors;
 }
 public PropertyErrorsException(PropertyError propertyError)
 {
     _propertyErrors = new PropertyErrors();
     _propertyErrors.Add(propertyError);
 }
 public PropertyErrorsException(PropertyErrors propertyErrors)
 {
     _propertyErrors = propertyErrors;
 }