Validating our options objects
Another feature that comes out of the box is options validation, which allows us to run validation code when a TOptions
object is created. The validation code is guaranteed to run the first time an option is created and does not account for subsequent option modifications. Depending on the lifetime of your options object, the validation may or may not run. For example:
Interface |
Lifetime |
Validation |
|
Singleton |
Validate the options once. |
|
Transient |
Validate the options every time the code calls the |