Ejemplo n.º 1
0
 public override IEnumerable <ModelValidationResult> Validate(object container)
 {
     if (rule.IsValid(container))
     {
         yield break;
     }
     yield return
         (new ModelValidationResult
     {
         Message = rule.FormatErrorMessage(Metadata.GetDisplayName())
     });
 }
Ejemplo n.º 2
0
        // TODO: write a test for this method using System.Web.Mvc.DefaultModelBinder.BindModel
        public override IEnumerable <ModelValidationResult> Validate(object container)
        {
            // container is useless because System.Web.Mvc.DefaultModelBinder passes null for it
            if (rule.IsValid(container ?? Metadata.Model))
            {
                yield break;
            }

            yield return(new ModelValidationResult
            {
                Message = rule.FormatErrorMessage(Metadata.GetDisplayName())
            });
        }