Skip to content

Commit d69c466

Browse files
committed
Add doc comments
1 parent 98cad73 commit d69c466

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/Http/Http.Abstractions/src/Validation/ValidatableContext.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,29 @@ namespace Microsoft.AspNetCore.Http.Validation;
1010
/// </summary>
1111
public sealed class ValidatableContext
1212
{
13+
/// <summary>
14+
/// Gets or sets the validation context used for validating objects that implement <see cref="IValidatableObject"/> or have <see cref="ValidationAttribute"/>.
15+
/// This context provides access to service provider and other validation metadata.
16+
/// </summary>
1317
public ValidationContext? ValidationContext { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the prefix used to identify the current object being validated in a complex object graph.
21+
/// This is used to build property paths in validation error messages (e.g., "Customer.Address.Street").
22+
/// </summary>
1423
public string Prefix { get; set; } = string.Empty;
24+
25+
/// <summary>
26+
/// Gets or sets the validation options that control validation behavior,
27+
/// including validation depth limits and resolver registration.
28+
/// </summary>
1529
public required ValidationOptions ValidationOptions { get; set; }
30+
31+
/// <summary>
32+
/// Gets or sets the dictionary of validation errors collected during validation.
33+
/// Keys are property names or paths, and values are arrays of error messages.
34+
/// This dictionary is lazily initialized when the first validation error is added.
35+
/// </summary>
1636
public Dictionary<string, string[]>? ValidationErrors { get; set; }
1737

1838
internal void AddValidationError(string key, string[] error)

src/Http/Http.Abstractions/src/Validation/ValidationOptions.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,35 @@
66

77
namespace Microsoft.AspNetCore.Http.Validation;
88

9+
/// <summary>
10+
/// Provides configuration options for the validation system.
11+
/// </summary>
912
public class ValidationOptions
1013
{
14+
/// <summary>
15+
/// Gets the list of resolvers that provide validation metadata for types and parameters.
16+
/// Resolvers are processed in order, with the first resolver providing a non-null result being used.
17+
/// </summary>
18+
/// <remarks>
19+
/// Source-generated resolvers are typically inserted at the beginning of this list
20+
/// to ensure they are checked before any runtime-based resolvers.
21+
/// </remarks>
1122
public IList<IValidatableInfoResolver> Resolvers { get; } = [];
23+
24+
/// <summary>
25+
/// Gets or sets the maximum depth for validation of nested objects.
26+
/// This prevents stack overflows from circular references or extremely deep object graphs.
27+
/// Default value is 32.
28+
/// </summary>
1229
public int MaxDepth { get; set; } = 32;
1330

31+
/// <summary>
32+
/// Attempts to get validation information for the specified type.
33+
/// </summary>
34+
/// <param name="type">The type to get validation information for.</param>
35+
/// <param name="validatableTypeInfo">When this method returns, contains the validation information for the specified type,
36+
/// if the type was found; otherwise, null.</param>
37+
/// <returns>true if validation information was found for the specified type; otherwise, false.</returns>
1438
public bool TryGetValidatableTypeInfo(Type type, [NotNullWhen(true)] out ValidatableTypeInfo? validatableTypeInfo)
1539
{
1640
foreach (var resolver in Resolvers)
@@ -26,6 +50,13 @@ public bool TryGetValidatableTypeInfo(Type type, [NotNullWhen(true)] out Validat
2650
return false;
2751
}
2852

53+
/// <summary>
54+
/// Attempts to get validation information for the specified parameter.
55+
/// </summary>
56+
/// <param name="parameterInfo">The parameter to get validation information for.</param>
57+
/// <param name="validatableParameterInfo">When this method returns, contains the validation information for the specified parameter,
58+
/// if validation information was found; otherwise, null.</param>
59+
/// <returns>true if validation information was found for the specified parameter; otherwise, false.</returns>
2960
public bool TryGetValidatableParameterInfo(ParameterInfo parameterInfo, [NotNullWhen(true)] out ValidatableParameterInfo? validatableParameterInfo)
3061
{
3162
foreach (var resolver in Resolvers)

0 commit comments

Comments
 (0)