Closed Jpadilla1 closed 3 years ago
This looks good and @eluciano11 has given his 👍🏼 in #171.
I do have one question. Are you looking to implement a rules engine? If so https://github.com/froi/simple-rules-engine/ might help you with some ideas, boilerplate, or just a a dependency to use.
lol yeah this is pretty much a rules engine
For clarity we are moving forward with this approach #171
Is your feature request related to a problem? Please describe. We require a ballot validator library where we can provide feedback to the user if the selections they have made are valid or not.
Describe the solution you'd like I have a proposed solution in this PR #171
Additional context The version linked here #171 can be described as a rule based approach. Where we have a validate function that accepts one of 3 Ballots and a BallotType. The return value is an object describing the status of the validation and the allowed & denied outcomes.
The way the rules work is by using a RuleGroup which has an array of rule instances to run against the ballot. Some rules are shared in between ballots and each rule only validates 1 thing. Example, the NoEmptyBallotRule checks if the ballot is empty. If it is the rule returns a deny outcome which means the ballot in invalid.
Rules of writing a rule:
Example output:
CC/ @code4puertorico/paravotar