<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0-rc.1.20451.14" />

System.ComponentModel.DataAnnotations.ValidationContext

public sealed class ValidationContext : IServiceProvider
Describes the context in which a validation check is performed.
public string DisplayName { get; set; }

Gets or sets the name of the member to validate.

public IDictionary<object, object> Items { get; }

Gets the dictionary of key/value pairs that is associated with this context.

public string MemberName { get; set; }

Gets or sets the name of the member to validate.

public object ObjectInstance { get; }

Gets the object to validate.

public Type ObjectType { get; }

Gets the type of the object to validate.

public ValidationContext(object instance)

Initializes a new instance of the ValidationContext class using the specified object instance.

public ValidationContext(object instance, IDictionary<object, object> items)

Initializes a new instance of the ValidationContext class using the specified object and an optional property bag.

public ValidationContext(object instance, IServiceProvider serviceProvider, IDictionary<object, object> items)

Initializes a new instance of the ValidationContext class using the service provider and dictionary of service consumers.

public object GetService(Type serviceType)

Returns the service that provides custom validation.

public void InitializeServiceProvider(Func<Type, object> serviceProvider)

Initializes the ValidationContext using a service provider that can return service instances by type when GetService is called.