예제 #1
0
        private string GetRequiredErrorMessage(ModelValidationContextBase validationContext)
        {
            if (validationContext == null)
            {
                throw new NullReferenceException(nameof(validationContext));
            }

            var msg = GenericResourceReader.GetValue <T>(CultureInfo.CurrentCulture.Name, DataAnnotationsErrorMessages.RequiredAttribute_ValidationError);

            return(string.Format(msg, validationContext.ModelMetadata.GetDisplayName()));
        }
예제 #2
0
        /// <summary>
        /// Get localized error message
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public override string GetErrorMessage(ModelValidationContextBase validationContext)
        {
            if (validationContext == null)
            {
                throw new NullReferenceException(nameof(validationContext));
            }

            var attLocalizedName = GenericResourceReader.GetValue <T>(CultureInfo.CurrentCulture.Name, _att);

            return(GetErrorMessage(validationContext.ModelMetadata, validationContext.ModelMetadata.GetDisplayName(), attLocalizedName));
        }