コード例 #1
0
ファイル: ValidationHelpers.cs プロジェクト: ymd1223/Mvc
        public static string GetModelErrorMessageOrDefault(ModelError modelError)
        {
            Debug.Assert(modelError != null);

            if (!string.IsNullOrEmpty(modelError.ErrorMessage))
            {
                return modelError.ErrorMessage;
            }

            // Default in the ValidationSummary case is no error message.
            return string.Empty;
        }
コード例 #2
0
ファイル: ValidationHelpers.cs プロジェクト: ymd1223/Mvc
        public static string GetModelErrorMessageOrDefault(
            ModelError modelError,
            ModelStateEntry containingEntry,
            ModelExplorer modelExplorer)
        {
            Debug.Assert(modelError != null);
            Debug.Assert(containingEntry != null);
            Debug.Assert(modelExplorer != null);

            if (!string.IsNullOrEmpty(modelError.ErrorMessage))
            {
                return modelError.ErrorMessage;
            }

            // Default in the ValidationMessage case is a fallback error message.
            var attemptedValue = containingEntry.AttemptedValue ?? "null";
            return modelExplorer.Metadata.ModelBindingMessageProvider.ValueIsInvalidAccessor(attemptedValue);
        }
コード例 #3
0
 private static void AssertRequiredError(string key, ModelError error)
 {
     // Mono issue - https://github.com/aspnet/External/issues/19
     Assert.Equal(PlatformNormalizer.NormalizeContent(
         string.Format("The {0} field is required.", key)), error.ErrorMessage);
     Assert.Null(error.Exception);
 }