public override IEnumerable <ModelValidationResult> Validate(object container)
 {
     if (rule.IsValid(container))
     {
         yield break;
     }
     yield return
         (new ModelValidationResult
     {
         Message = rule.FormatErrorMessage(Metadata.GetDisplayName())
     });
 }
        // 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())
            });
        }