예제 #1
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            ErrorMessage = UmbracoValidationHelper.GetDictionaryItem(_errorMessageDictionaryKey, _defaultText);

            var error = FormatErrorMessage(metadata.DisplayName);
            var rule  = new ModelClientValidationEqualToRule(error, _otherProperty);

            yield return(rule);
        }
예제 #2
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            ErrorMessage = UmbracoValidationHelper.GetDictionaryItem(_errorMessageDictionaryKey, _defaultText);

            var error = UmbracoValidationHelper.FormatErrorMessage(metadata.DisplayName, _errorMessageDictionaryKey, _defaultText);
            var rule  = new ModelClientValidationRangeRule(error, Minimum, Maximum);

            yield return(rule);
        }
예제 #3
0
        static public void TrySetErrorMessage(this ValidationAttribute attr, string dictionaryKey)
        {
            if (string.IsNullOrEmpty(dictionaryKey))
            {
                return;
            }

            var item = UmbracoValidationHelper.GetDictionaryItem(dictionaryKey);

            if (item != dictionaryKey)
            {
                // dictionaryKey has entry in dictionary, use entry value as error message
                attr.ErrorMessage = item;
            }
            else
            {
                // dictionaryKey does not have entry in dictionary, assume it is error message
                attr.ErrorMessage = dictionaryKey;
            }
        }