Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="metadata"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            // var title = UmbracoValidationHelper.GetDictionaryItem(_titleDictionaryKey);
            //var msg = UmbracoValidationHelper.GetDictionaryItem(_errorMessageDictionaryKey);
            ErrorMessage = _errorMessageDictionaryKey;
            if (System.Globalization.CultureInfo.CurrentCulture.Name == "ar")
            {
                if (_errorMessageDictionaryKey == "Name is required")
                {
                    ErrorMessage = "مطلوب اسم";
                }
                else if (_errorMessageDictionaryKey == "Email Address is required")
                {
                    ErrorMessage = "مطلوب عنوان البريد الإلكتروني";
                }
                else if (_errorMessageDictionaryKey == "Subject is required")
                {
                    ErrorMessage = "مطلوب موضوع";
                }
                else if (_errorMessageDictionaryKey == "Phone is required")
                {
                    ErrorMessage = "الهاتف مطلوب";
                }
            }
            var error = FormatErrorMessage(metadata.DisplayName);
            var rule  = new ModelClientValidationRequiredRule(error);

            yield return(rule);
        }
Example #2
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            ErrorMessage = UmbracoPropertyValidationHelper.GetPropertyValueItem(_errorMessageKey);
            var error = FormatErrorMessage(metadata.DisplayName);
            var rule  = new ModelClientValidationRequiredRule(error);

            yield return(rule);
        }
        public static IValidator Required(string errorMessage = null)
        {
            errorMessage = DefaultIfEmpty(errorMessage, WebPageResources.ValidationDefault_Required);
            var clientAttributes = new ModelClientValidationRequiredRule(errorMessage);

            // We don't care if the value is unsafe when verifying that it is required.
            return(new ValidationAttributeAdapter(new RequiredAttribute(), errorMessage, clientAttributes, useUnvalidatedValues: true));
        }
Example #4
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(
            ModelMetadata metadata,
            ControllerContext context)
        {
            var rule = new ModelClientValidationRequiredRule(ErrorMessageString);

            return(new[] { rule });
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="metadata"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            ErrorMessage = UmbracoValidationHelper.GetDictionaryItem(_errorMessageDictionaryKey, _defaultText);

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

            yield return(rule);
        }
Example #6
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            var required = new ModelClientValidationRequiredRule(String.Format(ErrorMessageString, metadata.DisplayName))
            {
                ValidationType = "requiredif"
            };

            required.ValidationParameters["other"]     = (context as ViewContext).ViewData.TemplateInfo.GetFullHtmlFieldId(OtherProperty);
            required.ValidationParameters["condition"] = Condition.ToString();
            required.ValidationParameters["value"]     = Value;
            yield return(required);
        }
        /// <summary>Gets a list of required-value client validation rules.</summary>
        /// <returns>A list of required-value client validation rules.</returns>
        public override IEnumerable <ModelClientValidationRule> GetClientValidationRules()
        {
            var rule = new ModelClientValidationRequiredRule(base.ErrorMessage);

            if (!base.Attribute.IsRequiredForRoles && base.Attribute.IsAuthenticated)
            {
                //setting "true" rather than bool true which is serialized as "True"
                rule.ValidationParameters["allowempty"] = "true";
            }

            return(new ModelClientValidationRequiredRule[] { rule });
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="metadata"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            var item = UmbracoValidationHelper.GetDictionaryItem(_errorMessageDictionaryKeyOrFallback);

            // Make sure that item is not just the default key
            if (item != DEFAULT_ERROR_MESSAGE_DICTIONARY_KEY)
            {
                // item is not the default key

                // Try to format error message with specified key or fallback
                this.TrySetErrorMessage(_errorMessageDictionaryKeyOrFallback);
            }

            var error = FormatErrorMessage(metadata.DisplayName);
            var rule  = new ModelClientValidationRequiredRule(error);

            yield return(rule);
        }
    public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
    {
        var rule = new ModelClientValidationRequiredRule(String.Format(ErrorMessages.FieldRequired, metadata.DisplayName));

        return(new[] { rule });
    }
Example #10
0
        public override IEnumerable <ModelClientValidationRule> GetClientValidationRules()
        {
            var rule = new ModelClientValidationRequiredRule(_message);

            return(new[] { rule });
        }
Example #11
0
        public IEnumerable <ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            var modelClientValidationRule = new ModelClientValidationRequiredRule(FormatErrorMessage(metadata.DisplayName));

            yield return(modelClientValidationRule);
        }