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

StringValidatorAttribute

Declaratively instructs .NET to perform string validation on a configuration property. This class cannot be inherited.
namespace System.Configuration { [AttributeUsage(AttributeTargets.Property)] public sealed class StringValidatorAttribute : ConfigurationValidatorAttribute { private int _maxLength = 2147483647; private int _minLength; public override ConfigurationValidatorBase ValidatorInstance => new StringValidator(_minLength, _maxLength, InvalidCharacters); public int MinLength { get { return _minLength; } set { if (_maxLength < value) throw new ArgumentOutOfRangeException("value", System.SR.Validator_min_greater_than_max); _minLength = value; } } public int MaxLength { get { return _maxLength; } set { if (_minLength > value) throw new ArgumentOutOfRangeException("value", System.SR.Validator_min_greater_than_max); _maxLength = value; } } public string InvalidCharacters { get; set; } } }