Add validation checks to BasePolicy constructor for robust error handling
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
## Problem / Motivation
Currently, the `BasePolicy` abstract class initializes its properties without validating input parameters. If invalid, empty, or malformed parameters (such as an incorrect `minimumVersion` format or missing critical fields) are passed by derived classes, it can lead to runtime issues or unexpected behaviors later in the rendering pipeline.
## Proposed Solution
- Add defensive validation checks inside the `BasePolicy` constructor.
- Validate that mandatory fields (`type`, `name`, `category`, `description`, `moduleName`) are provided and correctly typed.
- Implement a regex check on `minimumVersion` to ensure proper semantic version formatting.
- Throw descriptive `Error` instances immediately upon receiving invalid initialization arguments to ease debugging.
Contributor guide
Assessment
This issue has not been assessed yet.