Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: environment variables validation
Refactor environment variable validation rules. Apply consistent patterns to env validation. The main motivation for this change was as follows: 1. Make env validation more strict and consistent. Stick to the same validation patterns in different projects. 2. Provide consistent fallback options for optional variables. Here are the main changes: 1. Previously if a user set an empty string as the variable name in the .env file like this: ``` VARIABLE_NAME= ``` not all variable initializers assigned a correct default value to the variable in this case. Now it is fixed. For the purpose of this improvement, now all optional variable initializers always have the `@Transform` decorator that provides a default value for the variable. Add the two special functions (`toNumber` and `toBoolean`) that support this change. 2. Make validation of boolean variables more strict. CAUTION: This might be a breaking change for users who use values like "yes" to initialize boolean variables. 3. Now the `ETH_NETWORK` variable is validated not only when the validator source is "Lido". Make validation of this variable more strict. CAUTION: Currently the EVM doesn't officially support testnets other than those listed in the `Network` interface. But this might be a breaking change if some users use EVM for other testnets. 4. Implement the new `toArrayOfUrls()` function to provide a reasonable default value for variables that should have a list of URLs in their values. This function also fixes a bug with default values for such variables. Previously, if a user set an empty string as a value of such variables, the validation worked incorrectly. 5. Now we validate that values in `EL_RPC_URLS`, `CL_API_URLS`, and `VALIDATOR_REGISTRY_KEYSAPI_SOURCE_URLS` are indeed URLs. 6. The validation engine now removes trailing slashes from URL values. 7. More consistent validation for the `HTTP_PORT` and `DB_PORT` values. 8. Add `@Optional` decorator to all optional variables. 9. Change `@IsNumber` to `@IsInt`. 10. Move enums from the `env.validation.ts` to `environment.interface.ts`.
- Loading branch information