2 types derived from RequiredAttribute
Microsoft.AspNetCore.Mvc.DataAnnotations.Test (2)
DataAnnotationsModelValidatorProviderTest.cs (2)
222public class CustomRequiredAttribute1 : RequiredAttribute 226public class CustomRequiredAttribute2 : RequiredAttribute
274 instantiations of RequiredAttribute
ApiExplorerWebSite (1)
Models\Product.cs (1)
14[Required]
Aspire.Dashboard (4)
Model\Otlp\FilterDialogFormModel.cs (3)
10[Required] 13[Required] 18[Required]
Model\TokenFormModel.cs (1)
11[Required(ErrorMessageResourceType = typeof(Login), ErrorMessageResourceName = nameof(Login.TokenRequiredErrorMessage))]
BasicWebSite (10)
Controllers\BindPropertiesWithValidationController.cs (2)
13[Required(ErrorMessage = "User name is required.")] 16[Required]
Models\LoginViewModel.cs (2)
10[Required] 14[Required]
Models\RemoteAttributeUser.cs (5)
14[Required(ErrorMessage = "UserId1 is required")] 19[Required(ErrorMessage = "UserId2 is required")] 23[Required(ErrorMessage = "UserId3 is required")] 31[Required(ErrorMessage = "UserId4 is required")] 39[Required(ErrorMessage = "UserId5 is required")]
Models\User.cs (1)
11[Required]
FormatterWebSite (16)
Controllers\JsonFormatterController.cs (2)
106[Required] 110[Required]
Controllers\TopLevelValidationController.cs (6)
14[BindProperty, Required] public int RequiredProp { get; set; } 16[BindProperty, Required, BindRequired] public int RequiredAndBindRequiredProp { get; set; } 22[Required] public int UnboundRequiredProp { get; set; } 27[BindProperty, BindNever, Required] public string BindNeverRequiredProp { get; set; } 31[Required] int requiredParam, 33[Required, BindRequired] int requiredAndBindRequiredParam,
Models\DerivedModel.cs (1)
10[Required]
Models\Developer.cs (1)
10[Required]
Models\InvalidModel.cs (1)
10[Required]
Models\RecursiveIdentifier.cs (1)
16[Required]
Models\User.cs (2)
13[Required, Range(1, 2000)] 17[Required, MinLength(5)]
Models\ValidationProviderAttributeModel.cs (2)
25new RequiredAttribute(), 38new RequiredAttribute()
HtmlGenerationWebSite (6)
Models\CustomerRecord.cs (2)
15[Required] 29[Required]
Models\Person.cs (1)
25[Required]
Models\Product.cs (1)
10[Required]
Models\ValidationProviderAttributeModel.cs (2)
25new RequiredAttribute(), 38new RequiredAttribute()
Identity.DefaultUI.WebSite (1)
Pages\Contoso\Login.cshtml.cs (1)
25[Required]
Identity.ExternalClaims (15)
Pages\Account\ExternalLogin.cshtml.cs (1)
45[Required]
Pages\Account\ForgotPassword.cshtml.cs (1)
32[Required]
Pages\Account\Login.cshtml.cs (2)
41[Required] 45[Required]
Pages\Account\LoginWith2fa.cshtml.cs (1)
37[Required]
Pages\Account\LoginWithRecoveryCode.cshtml.cs (1)
36[Required]
Pages\Account\Manage\ChangePassword.cshtml.cs (2)
41[Required] 46[Required]
Pages\Account\Manage\EnableAuthenticator.cshtml.cs (1)
48[Required]
Pages\Account\Manage\Index.cshtml.cs (1)
46[Required]
Pages\Account\Manage\SetPassword.cshtml.cs (1)
37[Required]
Pages\Account\Register.cshtml.cs (2)
44[Required] 49[Required]
Pages\Account\ResetPassword.cshtml.cs (2)
30[Required] 34[Required]
IdentitySample.DefaultUI (6)
Areas\Identity\Pages\Account\Manage\Index.cshtml.cs (2)
39[Required] 44[Required]
Areas\Identity\Pages\Account\Register.cshtml.cs (4)
43[Required] 48[Required] 59[Required] 64[Required]
IdentitySample.Mvc (19)
Models\AccountViewModels\ExternalLoginConfirmationViewModel.cs (1)
10[Required]
Models\AccountViewModels\ForgotPasswordViewModel.cs (1)
10[Required]
Models\AccountViewModels\LoginViewModel.cs (2)
10[Required] 14[Required]
Models\AccountViewModels\RegisterViewModel.cs (2)
10[Required] 15[Required]
Models\AccountViewModels\ResetPasswordViewModel.cs (2)
10[Required] 14[Required]
Models\AccountViewModels\UseRecoveryCodeViewModel.cs (1)
10[Required]
Models\AccountViewModels\VerifyAuthenticatorCodeViewModel.cs (1)
10[Required]
Models\AccountViewModels\VerifyCodeViewModel.cs (2)
10[Required] 13[Required]
Models\ManageViewModels\AddPhoneNumberViewModel.cs (1)
10[Required]
Models\ManageViewModels\ChangePasswordViewModel.cs (2)
10[Required] 15[Required]
Models\ManageViewModels\DisplayRecoveryCodesViewModel.cs (1)
10[Required]
Models\ManageViewModels\SetPasswordViewModel.cs (1)
10[Required]
Models\ManageViewModels\VerifyPhoneNumberViewModel.cs (2)
10[Required] 13[Required]
Microsoft.AspNetCore.Components.Forms.Tests (4)
EditContextDataAnnotationsExtensionsTest.cs (4)
185[Required(ErrorMessage = "RequiredString:required")] public string RequiredString { get; set; } 190[Required] public string ThisWillNotBeValidatedBecauseItIsAField; 191[Required] string ThisWillNotBeValidatedBecauseItIsPrivate { get; set; } 192[Required] internal string ThisWillNotBeValidatedBecauseItIsInternal { get; set; }
Microsoft.AspNetCore.Diagnostics.Middleware (5)
Logging\LoggingRedactionOptions.cs (4)
57[Required] 68[Required] 79[Required] 99[Required]
Logging\RequestHeadersLogEnricherOptions.cs (1)
24[Required]
Microsoft.AspNetCore.Identity.UI (36)
Areas\Identity\Pages\V4\Account\ExternalLogin.cshtml.cs (1)
61[Required]
Areas\Identity\Pages\V4\Account\ForgotPassword.cshtml.cs (1)
39[Required]
Areas\Identity\Pages\V4\Account\Login.cshtml.cs (2)
59[Required] 67[Required]
Areas\Identity\Pages\V4\Account\LoginWith2fa.cshtml.cs (1)
50[Required]
Areas\Identity\Pages\V4\Account\LoginWithRecoveryCode.cshtml.cs (1)
45[Required]
Areas\Identity\Pages\V4\Account\Manage\ChangePassword.cshtml.cs (2)
42[Required] 51[Required]
Areas\Identity\Pages\V4\Account\Manage\DeletePersonalData.cshtml.cs (1)
35[Required]
Areas\Identity\Pages\V4\Account\Manage\Email.cshtml.cs (1)
56[Required]
Areas\Identity\Pages\V4\Account\Manage\EnableAuthenticator.cshtml.cs (1)
65[Required]
Areas\Identity\Pages\V4\Account\Manage\SetPassword.cshtml.cs (1)
41[Required]
Areas\Identity\Pages\V4\Account\Register.cshtml.cs (2)
55[Required] 64[Required]
Areas\Identity\Pages\V4\Account\ResendEmailConfirmation.cshtml.cs (1)
39[Required]
Areas\Identity\Pages\V4\Account\ResetPassword.cshtml.cs (3)
38[Required] 46[Required] 64[Required]
Areas\Identity\Pages\V5\Account\ExternalLogin.cshtml.cs (1)
61[Required]
Areas\Identity\Pages\V5\Account\ForgotPassword.cshtml.cs (1)
39[Required]
Areas\Identity\Pages\V5\Account\Login.cshtml.cs (2)
59[Required] 67[Required]
Areas\Identity\Pages\V5\Account\LoginWith2fa.cshtml.cs (1)
50[Required]
Areas\Identity\Pages\V5\Account\LoginWithRecoveryCode.cshtml.cs (1)
45[Required]
Areas\Identity\Pages\V5\Account\Manage\ChangePassword.cshtml.cs (2)
42[Required] 51[Required]
Areas\Identity\Pages\V5\Account\Manage\DeletePersonalData.cshtml.cs (1)
35[Required]
Areas\Identity\Pages\V5\Account\Manage\Email.cshtml.cs (1)
56[Required]
Areas\Identity\Pages\V5\Account\Manage\EnableAuthenticator.cshtml.cs (1)
65[Required]
Areas\Identity\Pages\V5\Account\Manage\SetPassword.cshtml.cs (1)
41[Required]
Areas\Identity\Pages\V5\Account\Register.cshtml.cs (2)
55[Required] 64[Required]
Areas\Identity\Pages\V5\Account\ResendEmailConfirmation.cshtml.cs (1)
39[Required]
Areas\Identity\Pages\V5\Account\ResetPassword.cshtml.cs (3)
38[Required] 46[Required] 64[Required]
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (1)
DefaultApiDescriptionProviderTest.cs (1)
2440private void RequiredParameter([BindRequired, Required] string name)
Microsoft.AspNetCore.Mvc.Core.Test (34)
Controllers\ControllerBinderDelegateProviderTest.cs (1)
1385[Required, BindNever] public string RequiredButBindNeverProperty { get; set; }
Formatters\JsonInputFormatterTestBase.cs (1)
674[Required]
ModelBinding\Binders\ComplexObjectModelBinderTest.cs (2)
1191[Required(ErrorMessage = "Sample message")] 1283[Required(ErrorMessage = "This message comes from the [Required] attribute.")]
ModelBinding\Binders\ComplexTypeModelBinderTest.cs (2)
1366[Required(ErrorMessage = "Sample message")] 1458[Required(ErrorMessage = "This message comes from the [Required] attribute.")]
ModelBinding\Metadata\ModelAttributesTest.cs (7)
312[Required] 321[Required] 324[Required] 343[Required] 346[Required] 380[Required] 409[Required, Range(1, 100)] int validationAttributes,
ModelBinding\ModelBindingHelperTest.cs (1)
815[Required]
ModelBinding\ParameterBinderTest.cs (8)
95new RequiredAttribute() 100new RequiredAttribute(), 119new RequiredAttribute().FormatErrorMessage("My Display Name"), 127var attribute = new RequiredAttribute(); 838[Required] 852private void TestMethodWithAttributes([Required][AlwaysInvalid] Person person) { } 862[Required] 872[Required]
ModelBinding\Validation\ClientValidatorCacheTest.cs (4)
108[Required] 113private record TestRecordType([Required][StringLength(10)] string Property1); 115private record TestRecordTypeWithProperty([Required][StringLength(10)] string Property1) 117[Required]
ModelBinding\Validation\DefaultModelValidatorProviderTest.cs (2)
147var attributes = new object[] { new RequiredAttribute(), new CustomModelValidatorAttribute(), new BindRequiredAttribute(), }; 161var attributes = new object[] { new RequiredAttribute(), new BindRequiredAttribute(), };
ModelBinding\Validation\DefaultObjectValidatorTests.cs (5)
1188[Required] 1450[Required] 1488[Required] 1500[Required, StringLength(10)] 1503[Required]
ModelBinding\Validation\ValidatorCacheTest.cs (1)
69[Required]
Microsoft.AspNetCore.Mvc.Core.TestCommon (1)
ValidationAttributeUtil.cs (1)
12var attr = new RequiredAttribute();
Microsoft.AspNetCore.Mvc.DataAnnotations (2)
DataAnnotationsClientModelValidatorProvider.cs (1)
95new RequiredAttribute(),
DataAnnotationsMetadataProvider.cs (1)
365requiredAttribute = new RequiredAttribute()
Microsoft.AspNetCore.Mvc.DataAnnotations.Test (18)
DataAnnotationsClientModelValidatorProviderTest.cs (2)
54Validator = new RequiredAttributeAdapter(new RequiredAttribute(), stringLocalizer: null), 151[Required(ErrorMessage = "Custom Required Message")]
DataAnnotationsMetadataProviderTest.cs (5)
1108var required = new RequiredAttribute(); 1450new RequiredAttribute(), 1466new RequiredAttribute(), 1482var attributes = new Attribute[] { new RequiredAttribute() }; 1914[Required(ErrorMessage = "Test")]
DataAnnotationsModelValidatorProviderTest.cs (1)
207[Required(ErrorMessage = "Custom Required Message")]
DataAnnotationsModelValidatorTest.cs (4)
23var attribute = new RequiredAttribute(); 220new RequiredAttribute(), 235Assert.Equal(new RequiredAttribute().FormatErrorMessage("Length"), validationResult.Message); 245new RequiredAttribute(),
ModelMetadataProviderTest.cs (2)
330new RequiredAttribute(), 1021[Required]
RequiredAttributeAdapterTest.cs (3)
23var attribute = new RequiredAttribute(); 58var attribute = new RequiredAttribute(); 83var attribute = new RequiredAttribute();
ValidationAttributeAdapterProviderTest.cs (1)
40new RequiredAttribute(),
Microsoft.AspNetCore.Mvc.IntegrationTests (37)
ActionParametersIntegrationTest.cs (2)
952[Required, StringLength(3)] string requiredAndStringLengthParam, 979public void MyAction([Required] string Name, [ValidateNever] ModelWithIValidatableObject validatableObject)
BindPropertyIntegrationTest.cs (1)
304[Required, StringLength(3)] public string RequiredAndStringLengthProp { get; set; }
BodyValidationIntegrationTests.cs (5)
345[Required] 436[Required] 505[Required] 691[Required] 752[Required]
DictionaryModelBinderIntegrationTest.cs (1)
1433[Required]
Models\Product.cs (1)
26[Required]
Models\ProductDetails.cs (3)
10[Required] 13[Required] 16[Required]
Models\ProductViewModel.cs (2)
13[Required] 20[Required]
Models\Software.cs (1)
12[Required]
NullableReferenceTypeIntegrationTest.cs (1)
102[Required(ErrorMessage = "Test")]
TryValidateModelIntegrationTest.cs (1)
176[Required(ErrorMessage = "Property")]
ValidationIntegrationTests.cs (6)
159[Required] 242[Required] 338[Required] 425[Required] 515[Required] 2505private static void Validation_InifnitelyRecursiveModel_ValidationOnTopLevelParameterMethod([Required] RecursiveModel model) { }
ValidationWithRecordIntegrationTests.cs (13)
149private record Order1([Required] string CustomerName); 228private record Order2([Required] Person2 Customer); 312private record Person3(int Age, [Required] string Name); 395private record Order4([Required] List<Item4> Items); 478private record Order5([Required] int? ProductId, string Name); 2291private static void Validation_InifnitelyRecursiveModel_ValidationOnTopLevelParameterMethod([Required] RecursiveModel model) { } 2297[Required] 2333private record RecordTypeWithValidatorsOnPropertiesAndParameters([Required] string Property1) 2336[Required] 2372private record RecordTypeWithValidatorsOnMixOfPropertiesAndParameters([Required] string Property1, string Property2) 2375[Required] 2412private record RecordTypeWithPropertiesAndParameters([Required] string Property1) 2414[Required]
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (1)
src\Mvc\Mvc.Core\test\Formatters\JsonInputFormatterTestBase.cs (1)
674[Required]
Microsoft.AspNetCore.Mvc.RazorPages.Test (2)
Infrastructure\PageBinderFactoryTest.cs (2)
954[Required] 968public void OnPostWithValidation([Required] string name)
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (6)
Rendering\HtmlHelperCheckboxTest.cs (1)
862[Required]
Rendering\HtmlHelperHiddenTest.cs (2)
484var requiredMessage = new RequiredAttribute().FormatErrorMessage("Property2"); 983[Required]
Rendering\HtmlHelperPasswordTest.cs (1)
530[Required]
Rendering\HtmlHelperTextAreaTest.cs (1)
145[Required]
Rendering\HtmlHelperTextBoxTest.cs (1)
163[Required]
Microsoft.AspNetCore.OpenApi.Tests (8)
Services\OpenApiSchemaService\OpenApiSchemaService.ParameterSchemas.cs (4)
436builder.MapGet("/api-1", ([Required] string id) => { }); 437builder.MapGet("/api-2", ([Required] int? age) => { }); 438builder.MapGet("/api-3", ([Required] Guid guid) => { }); 439builder.MapGet("/api-4", ([Required][FromHeader] DateTime date) => { });
Services\OpenApiSchemaService\OpenApiSchemaService.RequestBodySchemas.cs (2)
128builder.MapPost("/required-poco", ([Required] Todo todo) => { }); 130builder.MapPost("/required-form", ([Required][FromForm] Todo todo) => { });
Shared\SharedTypes.cs (2)
64[Required] 66[Required]
Microsoft.Extensions.AmbientMetadata.Application (2)
ApplicationMetadata.cs (2)
26[Required] 32[Required]
Microsoft.Extensions.Compliance.Testing (1)
FakeRedactorOptions.cs (1)
23[Required]
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
ResourceMonitoringOptions.Windows.cs (1)
17[Required]
Microsoft.Extensions.Http.Diagnostics (5)
Logging\LoggingOptions.cs (5)
79[Required] 87[Required] 102[Required] 117[Required] 144[Required]
Microsoft.Extensions.Http.Resilience (15)
Hedging\HedgingEndpointOptions.cs (3)
26[Required] 39[Required] 53[Required]
Hedging\HttpStandardHedgingResilienceOptions.cs (3)
46[Required] 59[Required] 72[Required]
Resilience\HttpStandardResilienceOptions.cs (5)
38[Required] 51[Required] 64[Required] 77[Required] 91[Required]
Routing\OrderedGroupsRoutingOptions.cs (1)
23[Required]
Routing\UriEndpoint.cs (1)
24[Required]
Routing\WeightedGroupsRoutingOptions.cs (1)
29[Required]
Routing\WeightedUriEndpoint.cs (1)
24[Required]
Microsoft.Extensions.Telemetry.Abstractions (3)
Latency\Registration\LatencyContextRegistrationOptions.cs (3)
17[Required] 23[Required] 29[Required]
RazorPagesWebSite (7)
Models\UserModel.cs (1)
10[Required]
Pages\CustomModelTypeModel.cshtml.cs (2)
24[Required] 29[Required]
Pages\Validation\PageWithCompareValidation.cs (3)
13[Required(ErrorMessage = "User name is required.")] 17[Required(ErrorMessage = "Password is required.")] 24[Required] // Here to make sure we do not validate an unbound property.
Pages\Validation\PageWithValidation.cs (1)
13[Required(ErrorMessage = "Name is required.")]
Sample (2)
src\OpenApi\test\Microsoft.AspNetCore.OpenApi.Tests\Shared\SharedTypes.cs (2)
64[Required] 66[Required]
TagHelpersWebSite (1)
Models\Employee.cs (1)
21[Required]
XmlFormattersWebSite (4)
Models\Address.cs (2)
10[Required] 13[Required]
Models\Store.cs (2)
10[Required] 13[Required]
86 references to RequiredAttribute
Microsoft.Analyzers.Local.Tests (1)
ApiLifecycle\ApiLifecycleAnalyzerTest.cs (1)
88Assembly.GetAssembly(typeof(RequiredAttribute))!,
Microsoft.AspNetCore.Mvc.Core (1)
MvcOptions.cs (1)
104/// Gets or sets a value that determines if the inference of <see cref="RequiredAttribute"/> for
Microsoft.AspNetCore.Mvc.Core.Test (22)
ModelBinding\Metadata\ModelAttributesTest.cs (14)
22Assert.Single(attributes.Attributes.OfType<RequiredAttribute>()); 25Assert.Single(attributes.PropertyAttributes.OfType<RequiredAttribute>()); 70Assert.Single(attributes.Attributes.OfType<RequiredAttribute>()); 73Assert.Single(attributes.PropertyAttributes.OfType<RequiredAttribute>()); 88Assert.Single(attributes.Attributes.OfType<RequiredAttribute>()); 92Assert.Single(attributes.PropertyAttributes.OfType<RequiredAttribute>()); 108Assert.Single(attributes.Attributes.OfType<RequiredAttribute>()); 111Assert.Single(attributes.PropertyAttributes.OfType<RequiredAttribute>()); 126Assert.Single(attributes.Attributes.OfType<RequiredAttribute>()); 129Assert.Single(attributes.PropertyAttributes.OfType<RequiredAttribute>()); 166Assert.IsType<RequiredAttribute>(attributes.Attributes[0]); 171Assert.IsType<RequiredAttribute>(attributes.PropertyAttributes[0]); 208attribute => Assert.IsType<RequiredAttribute>(attribute), 212attribute => Assert.IsType<RequiredAttribute>(attribute),
ModelBinding\ParameterBinderTest.cs (4)
123public static TheoryData<RequiredAttribute, ParameterDescriptor, ModelMetadata> EnforcesTopLevelRequiredDataSet 127var attribute = new RequiredAttribute(); 174return new TheoryData<RequiredAttribute, ParameterDescriptor, ModelMetadata> 187RequiredAttribute attribute,
ModelBinding\Validation\ClientValidatorCacheTest.cs (2)
23var attribute1 = Assert.Single(validators1.OfType<RequiredAttributeAdapter>()).Attribute; 144if (attribute is RequiredAttribute)
ModelBinding\Validation\ValidatorCacheTest.cs (2)
61var requiredValidator = Assert.Single(validators2.Where(v => (v as DataAnnotationsModelValidator).Attribute is RequiredAttribute)); 99if (attribute is RequiredAttribute)
Microsoft.AspNetCore.Mvc.Core.TestCommon (1)
ValidationAttributeUtil.cs (1)
12var attr = new RequiredAttribute();
Microsoft.AspNetCore.Mvc.DataAnnotations (10)
DataAnnotationsClientModelValidatorProvider.cs (1)
79hasRequiredAttribute |= attribute is RequiredAttribute;
DataAnnotationsMetadataProvider.cs (2)
322var requiredAttribute = attributes.OfType<RequiredAttribute>().FirstOrDefault();
DataAnnotationsModelValidatorProvider.cs (1)
79if (attribute is RequiredAttribute)
RequiredAttributeAdapter.cs (4)
11/// <see cref="AttributeAdapterBase{TAttribute}"/> for <see cref="RequiredAttribute"/>. 13public sealed class RequiredAttributeAdapter : AttributeAdapterBase<RequiredAttribute> 18/// <param name="attribute">The <see cref="RequiredAttribute"/>.</param> 20public RequiredAttributeAdapter(RequiredAttribute attribute, IStringLocalizer? stringLocalizer)
ValidationAttributeAdapterProvider.cs (2)
34else if (typeof(RequiredAttribute).IsAssignableFrom(type)) 36return new RequiredAttributeAdapter((RequiredAttribute)attribute, stringLocalizer);
Microsoft.AspNetCore.Mvc.DataAnnotations.Test (24)
DataAnnotationsMetadataProviderTest.cs (18)
1108var required = new RequiredAttribute(); 1164var attribute = Assert.Single(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1165Assert.True(((RequiredAttribute)attribute).AllowEmptyStrings); // non-Default for [Required] 1189var attribute = Assert.Single(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute a); 1190Assert.Equal("Test", ((RequiredAttribute)attribute).ErrorMessage); 1191Assert.False(((RequiredAttribute)attribute).AllowEmptyStrings); // Default for [Required] 1219Assert.DoesNotContain(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1240Assert.Contains(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1259Assert.Contains(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1278Assert.DoesNotContain(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1299Assert.DoesNotContain(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1319Assert.Contains(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1338Assert.Contains(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1357Assert.Contains(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1376Assert.DoesNotContain(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1397Assert.DoesNotContain(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1418Assert.Contains(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute); 1439Assert.DoesNotContain(context.ValidationMetadata.ValidatorMetadata, m => m is RequiredAttribute);
DataAnnotationsModelValidatorProviderTest.cs (2)
55Assert.IsAssignableFrom<RequiredAttribute>(((DataAnnotationsModelValidator)providerContext.Results[0].Validator).Attribute); 56Assert.IsAssignableFrom<RequiredAttribute>(((DataAnnotationsModelValidator)providerContext.Results[1].Validator).Attribute);
DataAnnotationsModelValidatorTest.cs (1)
23var attribute = new RequiredAttribute();
RequiredAttributeAdapterTest.cs (3)
23var attribute = new RequiredAttribute(); 58var attribute = new RequiredAttribute(); 83var attribute = new RequiredAttribute();
Microsoft.AspNetCore.OpenApi (2)
Services\OpenApiDocumentService.cs (1)
447parameterInfoDescriptor.ParameterInfo.GetCustomAttributes(inherit: true).Any(attr => attr is RequiredAttribute);
Services\Schemas\OpenApiSchemaService.cs (1)
50.Any(attr => attr is RequiredAttribute);
Microsoft.Extensions.Compliance.Redaction (1)
src\Shared\Data.Validation\LengthAttribute.cs (1)
86/// It is assumed the <see cref = "RequiredAttribute" /> is used if the value may not be <see langword="null"/>.
Microsoft.Extensions.Diagnostics.Probes (1)
src\Shared\Data.Validation\LengthAttribute.cs (1)
86/// It is assumed the <see cref = "RequiredAttribute" /> is used if the value may not be <see langword="null"/>.
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
src\Shared\Data.Validation\LengthAttribute.cs (1)
86/// It is assumed the <see cref = "RequiredAttribute" /> is used if the value may not be <see langword="null"/>.
Microsoft.Extensions.Http.Resilience (1)
src\Shared\Data.Validation\LengthAttribute.cs (1)
86/// It is assumed the <see cref = "RequiredAttribute" /> is used if the value may not be <see langword="null"/>.
Microsoft.Extensions.Telemetry (1)
src\Shared\Data.Validation\LengthAttribute.cs (1)
86/// It is assumed the <see cref = "RequiredAttribute" /> is used if the value may not be <see langword="null"/>.
Shared (1)
Data.Validation\LengthAttribute.cs (1)
86/// It is assumed the <see cref = "RequiredAttribute" /> is used if the value may not be <see langword="null"/>.
System.ComponentModel.Annotations (18)
System\ComponentModel\DataAnnotations\LengthAttribute.cs (1)
38/// It is assumed the <see cref="RequiredAttribute" /> is used if the value may not be null.
System\ComponentModel\DataAnnotations\MaxLengthAttribute.cs (1)
58/// It is assumed the <see cref="RequiredAttribute" /> is used if the value may not be null.
System\ComponentModel\DataAnnotations\MinLengthAttribute.cs (1)
40/// It is assumed the <see cref="RequiredAttribute" /> is used if the value may not be null.
System\ComponentModel\DataAnnotations\StringLengthAttribute.cs (1)
40/// It is assumed the <see cref="RequiredAttribute" /> is used if the value may not be null.
System\ComponentModel\DataAnnotations\Validator.cs (14)
28/// If there is a <see cref="RequiredAttribute" /> found on the property, it will be evaluated before all other 33/// If <paramref name="validationResults" /> is null and there isn't a <see cref="RequiredAttribute" /> failure, 77/// checks to ensure all properties marked with <see cref="RequiredAttribute" /> are set. It does not validate the 104/// checks to ensure all properties marked with <see cref="RequiredAttribute" /> are set. If 115/// For any given property, if it has a <see cref="RequiredAttribute" /> that fails validation, no other validators 164/// If there is a <see cref="RequiredAttribute" /> within the <paramref name="validationAttributes" />, it will 170/// If <paramref name="validationResults" /> is null and there isn't a <see cref="RequiredAttribute" /> failure, 302/// A <see cref="RequiredAttribute" /> within the <paramref name="validationAttributes" /> will always be evaluated 456/// ones marked with <see cref="RequiredAttribute" /> are not null. 482if (attribute is RequiredAttribute reqAttr) 541/// If a <see cref="RequiredAttribute" /> is found, it will be evaluated first, and if that fails, 549/// <see cref="RequiredAttribute" /> failure will always abort with that sole failure. 562RequiredAttribute? required = null; 565required = attribute as RequiredAttribute;
System.ComponentModel.DataAnnotations (1)
System.ComponentModel.DataAnnotations.cs (1)
28[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ComponentModel.DataAnnotations.RequiredAttribute))]