RazorDocs Search
Example

Config validation example

Source of truth

View source Edit this page

Last updated

This sample shows scalar validation on a strongly typed AppSurface config wrapper.

Run it from the repository root:

Bashdotnet run --project examples/config-validation

The sample intentionally exits with a non-zero status so you can see the startup failure shape:

Plain textConfiguration validation failed for key 'PortConfig' (PortConfig -> Int32): 1 error(s).
- <value>: The configuration value must be between 1 and 65535.
Fix the configured value or relax the scalar rule on the config wrapper.

The failed value is not printed. Configuration values often include secrets, so validation output names the key and rule without echoing the attempted value.