80 instantiations of ValidationResult
BasketService (1)
Models\BasketItem.cs (1)
19results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" }));
FormatterWebSite (1)
Models\InvalidModel.cs (1)
15yield return new ValidationResult("The model is not valid.");
Microsoft.AspNetCore.Mvc.Core.Test (7)
ModelBinding\Validation\DefaultObjectValidatorTests.cs (7)
1545yield return new ValidationResult( 1548yield return new ValidationResult("Error2", new[] { "Property1" }); 1549yield return new ValidationResult("Error3", new[] { "Property2", "Property3" }); 1570yield return new ValidationResult("Parent not valid"); 1608yield return new ValidationResult("Password does not meet complexity requirements."); 1626return new ValidationResult( 1644return new ValidationResult(
Microsoft.AspNetCore.Mvc.DataAnnotations.Test (9)
DataAnnotationsModelValidatorTest.cs (1)
341.Returns(new ValidationResult(errorMessage, memberNames));
ValidatableObjectAdapterTest.cs (8)
65new[] { new ValidationResult("Error message") }, 69new[] { new ValidationResult("Error message", new[] { nameof(SampleModel.FirstName) }) }, 75new ValidationResult("Error message1"), 76new ValidationResult("Error message2", new[] { nameof(SampleModel.FirstName) }), 77new ValidationResult("Error message3", new[] { nameof(SampleModel.LastName) }), 78new ValidationResult("Error message4", new[] { nameof(SampleModel) }), 92new ValidationResult("Error message1", new[] 97new ValidationResult("Error message2"),
Microsoft.AspNetCore.Mvc.IntegrationTests (18)
ActionParametersIntegrationTest.cs (2)
898yield return new ValidationResult("Not valid."); 899yield return new ValidationResult("FirstName Not valid.", new string[] { nameof(FirstName) });
CompanyNameAttribute.cs (1)
15return new ValidationResult("CompanyName cannot be null or empty.");
ProductValidatorAttribute.cs (3)
17return new ValidationResult("Product must be made in the USA if it is not named."); 29return new ValidationResult("Product must be made in the USA if it is not named."); 37return new ValidationResult("Expected either ProductViewModel or SoftwareViewModel instance but got "
ValidationIntegrationTests.cs (6)
897return new ValidationResult("Invalid Person."); 1004return new ValidationResult("Invalid Product."); 1300var result = new ValidationResult( 1318return new ValidationResult( 2202yield return new ValidationResult("Failed validation"); 2413return new ValidationResult("Invalid result");
ValidationWithRecordIntegrationTests.cs (6)
766return new ValidationResult("Invalid Person."); 866return new ValidationResult("Invalid Product."); 1150var result = new ValidationResult( 1168return new ValidationResult( 1993yield return new ValidationResult("Failed validation"); 2201return new ValidationResult("Invalid result");
Microsoft.Extensions.Compliance.Redaction (6)
src\Shared\Data.Validation\LengthAttribute.cs (2)
175return new ValidationResult(FormatErrorMessage(validationContext.GetDisplayName()), validationContext.GetMemberName()); 184return new ValidationResult(validationMessage, validationContext.GetMemberName());
src\Shared\Data.Validation\TimeSpanAttribute.cs (4)
134return new ValidationResult($"The field {validationContext.GetDisplayName()} must be > to {min}.", validationContext.GetMemberName()); 139return new ValidationResult($"The field {validationContext.GetDisplayName()} must be >= to {min}.", validationContext.GetMemberName()); 146return new ValidationResult($"The field {validationContext.GetDisplayName()} must be < to {max}.", validationContext.GetMemberName()); 151return new ValidationResult($"The field {validationContext.GetDisplayName()} must be <= to {max}.", validationContext.GetMemberName());
Microsoft.Extensions.Diagnostics.Probes (6)
src\Shared\Data.Validation\LengthAttribute.cs (2)
175return new ValidationResult(FormatErrorMessage(validationContext.GetDisplayName()), validationContext.GetMemberName()); 184return new ValidationResult(validationMessage, validationContext.GetMemberName());
src\Shared\Data.Validation\TimeSpanAttribute.cs (4)
134return new ValidationResult($"The field {validationContext.GetDisplayName()} must be > to {min}.", validationContext.GetMemberName()); 139return new ValidationResult($"The field {validationContext.GetDisplayName()} must be >= to {min}.", validationContext.GetMemberName()); 146return new ValidationResult($"The field {validationContext.GetDisplayName()} must be < to {max}.", validationContext.GetMemberName()); 151return new ValidationResult($"The field {validationContext.GetDisplayName()} must be <= to {max}.", validationContext.GetMemberName());
Microsoft.Extensions.Diagnostics.ResourceMonitoring (6)
src\Shared\Data.Validation\LengthAttribute.cs (2)
175return new ValidationResult(FormatErrorMessage(validationContext.GetDisplayName()), validationContext.GetMemberName()); 184return new ValidationResult(validationMessage, validationContext.GetMemberName());
src\Shared\Data.Validation\TimeSpanAttribute.cs (4)
134return new ValidationResult($"The field {validationContext.GetDisplayName()} must be > to {min}.", validationContext.GetMemberName()); 139return new ValidationResult($"The field {validationContext.GetDisplayName()} must be >= to {min}.", validationContext.GetMemberName()); 146return new ValidationResult($"The field {validationContext.GetDisplayName()} must be < to {max}.", validationContext.GetMemberName()); 151return new ValidationResult($"The field {validationContext.GetDisplayName()} must be <= to {max}.", validationContext.GetMemberName());
Microsoft.Extensions.Http.Resilience (6)
src\Shared\Data.Validation\LengthAttribute.cs (2)
175return new ValidationResult(FormatErrorMessage(validationContext.GetDisplayName()), validationContext.GetMemberName()); 184return new ValidationResult(validationMessage, validationContext.GetMemberName());
src\Shared\Data.Validation\TimeSpanAttribute.cs (4)
134return new ValidationResult($"The field {validationContext.GetDisplayName()} must be > to {min}.", validationContext.GetMemberName()); 139return new ValidationResult($"The field {validationContext.GetDisplayName()} must be >= to {min}.", validationContext.GetMemberName()); 146return new ValidationResult($"The field {validationContext.GetDisplayName()} must be < to {max}.", validationContext.GetMemberName()); 151return new ValidationResult($"The field {validationContext.GetDisplayName()} must be <= to {max}.", validationContext.GetMemberName());
Microsoft.Extensions.Telemetry (6)
src\Shared\Data.Validation\LengthAttribute.cs (2)
175return new ValidationResult(FormatErrorMessage(validationContext.GetDisplayName()), validationContext.GetMemberName()); 184return new ValidationResult(validationMessage, validationContext.GetMemberName());
src\Shared\Data.Validation\TimeSpanAttribute.cs (4)
134return new ValidationResult($"The field {validationContext.GetDisplayName()} must be > to {min}.", validationContext.GetMemberName()); 139return new ValidationResult($"The field {validationContext.GetDisplayName()} must be >= to {min}.", validationContext.GetMemberName()); 146return new ValidationResult($"The field {validationContext.GetDisplayName()} must be < to {max}.", validationContext.GetMemberName()); 151return new ValidationResult($"The field {validationContext.GetDisplayName()} must be <= to {max}.", validationContext.GetMemberName());
MyFrontend (1)
playground\TestShop\BasketService\Models\BasketItem.cs (1)
19results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" }));
OrderProcessor (1)
playground\TestShop\BasketService\Models\BasketItem.cs (1)
19results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" }));
Shared (6)
Data.Validation\LengthAttribute.cs (2)
175return new ValidationResult(FormatErrorMessage(validationContext.GetDisplayName()), validationContext.GetMemberName()); 184return new ValidationResult(validationMessage, validationContext.GetMemberName());
Data.Validation\TimeSpanAttribute.cs (4)
134return new ValidationResult($"The field {validationContext.GetDisplayName()} must be > to {min}.", validationContext.GetMemberName()); 139return new ValidationResult($"The field {validationContext.GetDisplayName()} must be >= to {min}.", validationContext.GetMemberName()); 146return new ValidationResult($"The field {validationContext.GetDisplayName()} must be < to {max}.", validationContext.GetMemberName()); 151return new ValidationResult($"The field {validationContext.GetDisplayName()} must be <= to {max}.", validationContext.GetMemberName());
System.ComponentModel.Annotations (6)
System\ComponentModel\DataAnnotations\CompareAttribute.cs (2)
39return new ValidationResult(SR.Format(SR.CompareAttribute_UnknownProperty, OtherProperty)); 54return new ValidationResult(FormatErrorMessage(validationContext.DisplayName), memberNames);
System\ComponentModel\DataAnnotations\CustomValidationAttribute.cs (1)
150return new ValidationResult(SR.Format(SR.CustomValidationAttribute_Type_Conversion_Failed,
System\ComponentModel\DataAnnotations\ValidationAttribute.cs (2)
304return new ValidationResult(FormatErrorMessage(validationContext.DisplayName), memberNames); 442result = new ValidationResult(errorMessage, result.MemberNames);
System\ComponentModel\DataAnnotations\ValidationException.cs (1)
97_validationResult ??= new ValidationResult(Message);
183 references to ValidationResult
BasketService (2)
Models\BasketItem.cs (2)
13public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 15var results = new List<ValidationResult>();
FormatterWebSite (3)
Models\InvalidModel.cs (1)
13public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
Models\RecursiveIdentifier.cs (2)
21public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 23return Enumerable.Empty<ValidationResult>();
Microsoft.AspNetCore.Components.Forms (4)
EditContextDataAnnotationsExtensions.cs (4)
94var results = new List<ValidationResult>(); 98foreach (var result in CollectionsMarshal.AsSpan(results)) 113var validationResults = new List<ValidationResult>(); 118foreach (var validationResult in validationResults)
Microsoft.AspNetCore.Mvc.Core.Test (7)
ModelBinding\Validation\DefaultModelValidatorProviderTest.cs (1)
177public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
ModelBinding\Validation\DefaultObjectValidatorTests.cs (6)
603.Returns(new List<ValidationResult>()); 1543public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 1566public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 1604public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 1624protected override ValidationResult IsValid(object value, ValidationContext validationContext) 1642protected override ValidationResult IsValid(object value, ValidationContext validationContext)
Microsoft.AspNetCore.Mvc.DataAnnotations (4)
DataAnnotationsModelValidator.cs (1)
83var result = Attribute.GetValidationResult(validationContext.Model, context);
ValidatableObjectAdapter.cs (3)
45private static IEnumerable<ModelValidationResult> ConvertResults(IEnumerable<ValidationResult> results) 47foreach (var result in results) 49if (result != ValidationResult.Success)
Microsoft.AspNetCore.Mvc.DataAnnotations.Test (12)
DataAnnotationsModelValidatorTest.cs (4)
102.Returns(ValidationResult.Success) 194.Returns(ValidationResult.Success); 542protected override ValidationResult IsValid(object value, ValidationContext validationContext) 547public abstract ValidationResult IsValidPublic(object value, ValidationContext validationContext);
DefaultModelClientValidatorProviderTest.cs (1)
202public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
ValidatableObjectAdapterTest.cs (7)
58public static TheoryData<ValidationResult[], ModelValidationResult[]> Validate_ReturnsExpectedResultsData 62return new TheoryData<ValidationResult[], ModelValidationResult[]> 142ValidationResult[] innerResults, 148foreach (var result in innerResults) 189public IList<ValidationResult> ValidationResults { get; } = new List<ValidationResult>(); 200public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
Microsoft.AspNetCore.Mvc.IntegrationTests (19)
ActionParametersIntegrationTest.cs (1)
896public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
CompanyNameAttribute.cs (1)
10protected override ValidationResult IsValid(object value, ValidationContext validationContext)
ProductValidatorAttribute.cs (1)
10protected override ValidationResult IsValid(object value, ValidationContext validationContext)
ValidationIntegrationTests.cs (8)
889protected override ValidationResult IsValid(object value, ValidationContext validationContext) 996protected override ValidationResult IsValid(object value, ValidationContext validationContext) 1298public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 1300var result = new ValidationResult( 1309protected override ValidationResult IsValid(object value, ValidationContext validationContext) 1315return ValidationResult.Success; 2198public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 2411public static ValidationResult Validate(ValidationContext context)
ValidationWithRecordIntegrationTests.cs (8)
758protected override ValidationResult IsValid(object value, ValidationContext validationContext) 858protected override ValidationResult IsValid(object value, ValidationContext validationContext) 1148public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 1150var result = new ValidationResult( 1159protected override ValidationResult IsValid(object value, ValidationContext validationContext) 1165return ValidationResult.Success; 1989public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 2199public static ValidationResult Validate(ValidationContext context)
Microsoft.Extensions.Compliance.Redaction (7)
src\Shared\Data.Validation\LengthAttribute.cs (4)
94protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 109return ValidationResult.Success!; 152private ValidationResult Validate(int count, ValidationContext? validationContext) 187return ValidationResult.Success!;
src\Shared\Data.Validation\TimeSpanAttribute.cs (3)
114protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 127return ValidationResult.Success!; 155return ValidationResult.Success!;
Microsoft.Extensions.Diagnostics.Probes (7)
src\Shared\Data.Validation\LengthAttribute.cs (4)
94protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 109return ValidationResult.Success!; 152private ValidationResult Validate(int count, ValidationContext? validationContext) 187return ValidationResult.Success!;
src\Shared\Data.Validation\TimeSpanAttribute.cs (3)
114protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 127return ValidationResult.Success!; 155return ValidationResult.Success!;
Microsoft.Extensions.Diagnostics.ResourceMonitoring (7)
src\Shared\Data.Validation\LengthAttribute.cs (4)
94protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 109return ValidationResult.Success!; 152private ValidationResult Validate(int count, ValidationContext? validationContext) 187return ValidationResult.Success!;
src\Shared\Data.Validation\TimeSpanAttribute.cs (3)
114protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 127return ValidationResult.Success!; 155return ValidationResult.Success!;
Microsoft.Extensions.Http.Resilience (7)
src\Shared\Data.Validation\LengthAttribute.cs (4)
94protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 109return ValidationResult.Success!; 152private ValidationResult Validate(int count, ValidationContext? validationContext) 187return ValidationResult.Success!;
src\Shared\Data.Validation\TimeSpanAttribute.cs (3)
114protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 127return ValidationResult.Success!; 155return ValidationResult.Success!;
Microsoft.Extensions.Options (5)
ValidateOptionsResultBuilder.cs (5)
39/// Adds any validation error carried by the <see cref="ValidationResult"/> instance to this instance. 42public void AddResult(ValidationResult? result) 54/// Adds any validation error carried by the enumeration of <see cref="ValidationResult"/> instances to this instance. 57public void AddResults(IEnumerable<ValidationResult?>? results) 61foreach (ValidationResult? result in results)
Microsoft.Extensions.Options.DataAnnotations (5)
DataAnnotationValidateOptions.cs (5)
58var validationResults = new List<ValidationResult>(); 74private static bool TryValidateOptions(object options, string qualifiedName, List<ValidationResult> results, ref List<string>? errors, ref HashSet<object>? visited) 90foreach (ValidationResult result in results!) 116results ??= new List<ValidationResult>(); 124results ??= new List<ValidationResult>();
Microsoft.Extensions.Telemetry (7)
src\Shared\Data.Validation\LengthAttribute.cs (4)
94protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 109return ValidationResult.Success!; 152private ValidationResult Validate(int count, ValidationContext? validationContext) 187return ValidationResult.Success!;
src\Shared\Data.Validation\TimeSpanAttribute.cs (3)
114protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 127return ValidationResult.Success!; 155return ValidationResult.Success!;
MyFrontend (2)
playground\TestShop\BasketService\Models\BasketItem.cs (2)
13public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 15var results = new List<ValidationResult>();
OrderProcessor (2)
playground\TestShop\BasketService\Models\BasketItem.cs (2)
13public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) 15var results = new List<ValidationResult>();
Shared (7)
Data.Validation\LengthAttribute.cs (4)
94protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 109return ValidationResult.Success!; 152private ValidationResult Validate(int count, ValidationContext? validationContext) 187return ValidationResult.Success!;
Data.Validation\TimeSpanAttribute.cs (3)
114protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) 127return ValidationResult.Success!; 155return ValidationResult.Success!;
Shared.Tests (16)
Data.Validation\LengthAttributeTests.cs (10)
29var results = new List<ValidationResult>(); 85var results = new List<ValidationResult>(); 157var results = new List<ValidationResult>(); 214var results = new List<ValidationResult>(); 264var results = new List<ValidationResult>(); 342var results = new List<ValidationResult>(); 373var result = attr.GetValidationResult(value, context); 375Assert.NotEqual(ValidationResult.Success, result); 390var results = new List<ValidationResult>(); 410var results = new List<ValidationResult>();
Data.Validation\TimeSpanAttributeTests.cs (6)
27var results = new List<ValidationResult>(); 92var results = new List<ValidationResult>(); 155var results = new List<ValidationResult>(); 229var results = new List<ValidationResult>(); 250var result = attr.GetValidationResult(value, context); 252Assert.NotEqual(ValidationResult.Success, result);
System.ComponentModel.Annotations (59)
System\ComponentModel\DataAnnotations\CompareAttribute.cs (1)
34protected override ValidationResult? IsValid(object? value, ValidationContext validationContext)
System\ComponentModel\DataAnnotations\CustomValidationAttribute.cs (13)
14/// public static <see cref="ValidationResult" /> Method(object value) { ... } 17/// public static <see cref="ValidationResult" /> Method(object value, <see cref="ValidationContext" /> context) { 33/// The named <see cref="Method" /> must be public, static, return <see cref="ValidationResult" /> and take at 43/// If the method returns <see cref="ValidationResult" />.<see cref="ValidationResult.Success" />, that indicates 45/// Returning an instance of <see cref="ValidationResult" /> indicates that the value is not acceptable 49/// If the method returns a <see cref="ValidationResult" /> with a <c>null</c> 50/// <see cref="ValidationResult.ErrorMessage" /> 79/// <see cref="IsValid(object, ValidationContext)" />> to return a <see cref="ValidationResult" /> 137protected override ValidationResult? IsValid(object? value, ValidationContext validationContext) 168var result = (ValidationResult?)methodInfo!.Invoke(null, methodParams); 252if (!typeof(ValidationResult).IsAssignableFrom(methodInfo.ReturnType))
System\ComponentModel\DataAnnotations\IValidatableObject.cs (1)
10IEnumerable<ValidationResult> Validate(ValidationContext validationContext);
System\ComponentModel\DataAnnotations\ValidationAttribute.cs (17)
298private protected ValidationResult CreateFailedValidationResult(ValidationContext validationContext) 364return IsValid(value, null!) == ValidationResult.Success; 379/// When validation is valid, <see cref="ValidationResult.Success" />. 381/// When validation is invalid, an instance of <see cref="ValidationResult" />. 389protected virtual ValidationResult? IsValid(object? value, ValidationContext validationContext) 400? ValidationResult.Success 409/// If this method returns <see cref="ValidationResult.Success" />, then validation was successful, otherwise 410/// an instance of <see cref="ValidationResult" /> will be returned with a guaranteed non-null 411/// <see cref="ValidationResult.ErrorMessage" />. 419/// When validation is valid, <see cref="ValidationResult.Success" />. 421/// When validation is invalid, an instance of <see cref="ValidationResult" />. 430public ValidationResult? GetValidationResult(object? value, ValidationContext validationContext) 434var result = IsValid(value, validationContext); 483/// If that method doesn't return <see cref="ValidationResult.Success" />, this base method will throw 484/// a <see cref="ValidationException" /> containing the <see cref="ValidationResult" /> describing the problem. 490/// doesn't return <see cref="ValidationResult.Success" />. 501ValidationResult? result = GetValidationResult(value, validationContext);
System\ComponentModel\DataAnnotations\ValidationException.cs (3)
16private ValidationResult? _validationResult; 24public ValidationException(ValidationResult validationResult, ValidationAttribute? validatingAttribute, 96public ValidationResult ValidationResult =>
System\ComponentModel\DataAnnotations\ValidationResult.cs (6)
11/// Use the static <see cref="ValidationResult.Success" /> to represent successful validation. 20/// Gets a <see cref="ValidationResult" /> that indicates Success. 23/// The <c>null</c> value is used to indicate success. Consumers of <see cref="ValidationResult" />s 24/// should compare the values to <see cref="ValidationResult.Success" /> rather than checking for null. 26public static readonly ValidationResult? Success; 68protected ValidationResult(ValidationResult validationResult)
System\ComponentModel\DataAnnotations\Validator.cs (18)
26/// this method will add a <see cref="ValidationResult" /> to it for each validation failure. 42/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param> 50ICollection<ValidationResult>? validationResults) 87/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param> 96object instance, ValidationContext validationContext, ICollection<ValidationResult>? validationResults) => 121/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param> 134ICollection<ValidationResult>? validationResults, bool validateAllProperties) 161/// <paramref name="validationResults" /> is non-null, this method will add a <see cref="ValidationResult" /> 179/// <param name="validationResults">Optional collection to receive <see cref="ValidationResult" />s for the failures.</param> 186ICollection<ValidationResult>? validationResults, IEnumerable<ValidationAttribute> validationAttributes) 436foreach (ValidationResult result in results) 438if (result != ValidationResult.Success) 486var validationResult = reqAttr.GetValidationResult(property.Value, property.Key); 487if (validationResult != ValidationResult.Success) 615var validationResult = attribute.GetValidationResult(value, validationContext); 616if (validationResult != ValidationResult.Success) 636ValidationResult validationResult) 643internal ValidationResult ValidationResult { get; }
System.ComponentModel.DataAnnotations (1)
System.ComponentModel.DataAnnotations.cs (1)
45[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ComponentModel.DataAnnotations.ValidationResult))]