For full setup see:

How to use IOptions for Config Binding

Startup.cs

public class Startup
{
		...

    public void ConfigureServices(IServiceCollection services)
    {
        ...
			  services.AddOptions<MyConfigModel>()
		        .Bind(Configuration.GetSection("MyConfigValues"))
						.ValidateDataAnnotations();
				...
    }

		...
}

Data Class

public class MyConfigModel
{
    [RegularExpression(@"^[a-zA-Z''-'\\s]{1,40}$")]
    public string Hello { get; set; }
}

When getting the config value that doesn't match the regex:

Validation Options

Data Validation Annotations