Reputation: 16196
The user of my .NET application must provide 20-digit account number in the application configuration file. I am derived class from ConfigurationSection to work with custom sections.
[ConfigurationProperty("RECEIVED_ACCOUNT", IsRequired = true)]
public string RECEIVED_ACCOUNT
{
get { return (string)this["RECEIVED_ACCOUNT"]; }
set { this["RECEIVED_ACCOUNT"] = value; }
}
I could use StringValidator
. It provides MaxLength, MinLength and InvalidCharacters.
But it does not allow to limit allowed characters to 0-9
w
Upvotes: 1
Views: 635
Reputation: 41298
I would suggest using a Regular Expression Validator and setting the ValidationExpresison property to be
^\d{20}$
This will validate a number of exactly 20 digits:
Upvotes: 3