Implement CronValidator for KindCacheConfig cronExpr
Description:
This task involves implementing a custom CronValidator
to validate the cronExpr
field within the Kind
class. The validation must support standard cron expressions compatible with Spring's CronExpression
. Additionally, unit tests should be added to validate the CRON expressions directly and ensure proper validation logic.
Requirements:
-
Cron Expression Validation:
- Implement a
@ValidCron
annotation for validating CRON expressions compatible with Spring'sCronExpression
. - Create a
CronExpressionValidator
class to handle validation logic, ensuring the CRON expressions conform to the six-field format expected by Spring.
- Implement a
-
API and Services:
- Ensure that the
cronExpr
field in theKind
class is annotated with@ValidCron
. - The
cronExpr
field should be validated in all API endpoints whereKind
objects are created or updated. - Return appropriate error messages for invalid CRON expressions.
- Ensure that the
-
Unit Tests:
- Add unit tests to test the
CronExpressionValidator
directly, covering:- Valid CRON expressions
- Invalid CRON expressions
- Complex CRON expressions
- Blank or null CRON expressions
- Add unit tests to test the
-
Swagger Documentation:
- Update Swagger documentation to include validation rules and examples for the
cronExpr
field.
- Update Swagger documentation to include validation rules and examples for the
Acceptance Criteria:
-
The @ValidCron
annotation andCronExpressionValidator
have been implemented and applied to thecronExpr
field in theKind
class. -
Unit tests have been added to directly test the CronExpressionValidator
, covering various CRON expression scenarios (valid, invalid, complex, null, blank). -
The API properly validates CRON expressions and returns appropriate error messages. -
Swagger documentation is updated to reflect the validation rules for the cronExpr
field.
Edited by Rostislav Dublin (EPAM)