<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.4" />

StringValidatorAttribute

Declaratively instructs .NET to perform string validation on a configuration property. This class cannot be inherited.
public string InvalidCharacters { get; set; }

Gets or sets the invalid characters for the property.

public int MaxLength { get; set; }

Gets or sets the maximum length allowed for the string to assign to the property.

public int MinLength { get; set; }

Gets or sets the minimum allowed value for the string to assign to the property.

Initializes a new instance of the StringValidatorAttribute class.