Skip to main content
Version: Next

Configuration Validation

Sharkable automatically validates critical configuration at startup and fails fast with a clear error message, preventing runtime surprises.

What Gets Validated

The validator runs at the end of AddShark(). It checks:

CheckConditionError
JWT audiencesIf ConfigureJwt() is called with audiences, at least one audience must be providedJwtAudiences: at least one audience is required
JWT authorityIf ConfigureJwt() is called, authority must not be null/emptyJwtAuthority: authority is required
Multi-tenant resolverIf ConfigureMultiTenant() is called, ResolveTenant delegate must be setTenantOptions.ResolveTenant: must be configured

Failure Behavior

All validation errors are collected. If any fail, a SharkConfigurationException is thrown before the application starts:

Sharkable.SharkConfigurationException: Configuration validation failed:
- JwtAudiences: at least one audience is required
- TenantOptions.ResolveTenant: must be configured

Opt-out

Configuration validation cannot be disabled. It is designed to catch misconfigurations at startup rather than at runtime. If a validation rule is too strict for your scenario, pass valid (even if dummy) values to satisfy it, or file an issue.