/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Mvc/shared/Mvc.Core.TestCommon/ValidationAttributeUtil.cs
38 строк
1 KB
Pranav K
Use file scoped namespaces (#38076)
06 ноя 2021, 03:52
Не верифицирован
06 ноя 2021, 03:52
a450cb6
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.ComponentModel.DataAnnotations; namespace Microsoft.AspNetCore.Mvc.ModelBinding; public static class ValidationAttributeUtil { public static string GetRequiredErrorMessage(string field) { var attr = new RequiredAttribute(); return attr.FormatErrorMessage(field); } public static string GetStringLengthErrorMessage(int? minimumLength, int maximumLength, string field) { var attr = new StringLengthAttribute(maximumLength); if (minimumLength != null) { attr.MinimumLength = (int)minimumLength; } return attr.FormatErrorMessage(field); } public static string GetRegExErrorMessage(string pattern, string field) { var attr = new RegularExpressionAttribute(pattern); return attr.FormatErrorMessage(field); } public static string GetRangeErrorMessage(int min, int max, string field) { var attr = new RangeAttribute(min, max); return attr.FormatErrorMessage(field); } }