Ejemplo n.º 1
0
            private void UpdateErrorMessage(IStringLocalizer stringLocalizer, ValidationAttribute attribute, string propertyName)
            {
                if (CanUpdateErrorMessage(attribute))
                {
                    var validatorName = attribute.GetValidatorName();

                    attribute.ErrorMessage = propertyName != null
                        ? GetErrorMessage(stringLocalizer, propertyName, validatorName)
                        : stringLocalizer[validatorName];
                }
            }
        private void UpdateErrorMessage(IStringLocalizer stringLocalizer, ValidationMetadataProviderContext context, ValidationAttribute attribute)
        {
            if (CanUpdateErrorMessage(attribute))
            {
                var propertyName  = context.Key.Name;
                var validatorName = attribute.GetValidatorName();

                attribute.ErrorMessage = propertyName != null
                    ? GetErrorMessageKey(stringLocalizer, propertyName, validatorName)
                    : validatorName;
            }
        }