Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADR: Write a custom validation DSL #9

Open
stijn-dejongh opened this issue Nov 16, 2024 · 1 comment · Fixed by #10
Open

ADR: Write a custom validation DSL #9

stijn-dejongh opened this issue Nov 16, 2024 · 1 comment · Fixed by #10
Assignees
Labels
ADR Architectural Decision Record enhancement New feature or request

Comments

@stijn-dejongh
Copy link
Member

stijn-dejongh commented Nov 16, 2024

Generate validator code from PlantUML custom theme specification

Context

Most organizations have business-minded individuals or non-software engineers defining the specifications of the software (internal clients, product owners, analysts, managers, end-users).

Problem

Business validation rules are tedious to maintain, as the translation from business specification into executable validation code involves multiple hand-overs and knowledge-extraction events. In the end, there is seldom time to maintain this consistently.

Current "Behaviour Driven Development" approaches lack the direct feedback to the end users, and are rather verbose
(cfr. Cucumber, Gherkin, Finesse, JBehave, ...)

Intent

  • ’maintainability:‘ significant increase
  • ‘adaptability:‘ significant increase

Solution

  • Work with file based validation inputs only, to simplify process and allow for extensibility. ( If your data can be written to a file, it can be validated. Covering most of the real-world use cases for backend BDD approaches).
  • Use a minimal plantUML based specification
  • Write a plantUML to executable code parser

Reasoning

  • Out of the box documentation due to PlantUML visualisation
  • Out of the box syntax checks due to PlantUML
  • Compatibility with most tech stacks
  • Specification can be kept, even if validation framework is removed

Considered alternatives

  • Write a custom<insert BDD spec> to ModularValidator implementation: rejected due to stack/dependency impact.
  • Write a Kotlin based DSL: rejected due to language onboarding requirements.
  • Use an existing tool: rejected as that would defeat the purpose of this project.

References

Example: Potential DSL API

ValidatorFor(".*IDENTIFIABLE_PART_OF_FILE_NAME.*\\.csv") {
   RecordIdentifier('ROW_ID')
   FieldMatches('FIELD_NAME', 'MAY_NOT_BE_EMPTY')
   FieldExists('JOSKE_WAS_HERE')
   
   ValidationCase("description") {
     RecordExists('12345')
     RecordHasValue('12345', 'FIELD_NAME', 'expectedValue')
   }
}
@stijn-dejongh stijn-dejongh added enhancement New feature or request ADR Architectural Decision Record labels Nov 16, 2024
@stijn-dejongh stijn-dejongh self-assigned this Nov 16, 2024
@stijn-dejongh stijn-dejongh pinned this issue Nov 16, 2024
@stijn-dejongh stijn-dejongh added this to the real-world-usage milestone Nov 16, 2024
@stijn-dejongh
Copy link
Member Author

stijn-dejongh commented Nov 16, 2024

Implementation plan

  • must: write plantUML theme to visualize validation requirements
  • must parse example spec at runtime to feed the ModularValitaorBuilder
  • should: Write code generator so Validators can be generated at build-time to increase performance
  • should: Allow for file structure specification
  • could: write maven plugin for QOL and reuse
  • dream: write pipeline that takes github issue w/ specification (issue template), generates code, and raises PR

Reasoning

  • limit scope to csv files for now
  • KISS: only support default file structure. validate usefulness first

@stijn-dejongh stijn-dejongh linked a pull request Nov 22, 2024 that will close this issue
@stijn-dejongh stijn-dejongh reopened this Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADR Architectural Decision Record enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant