Implementing a Rule Container with Effect and Context in TypeScript

HHi all, I would like to have some guidance, I want t o have multiple Rules as Services and some kind of Container to hold these rules. I thought about something like this which doesn't work. Maybe Services inst't the right way to go but out of curiosity how could something like this be implemented? Thx in advance
// Playing around
export class TimesheetRules extends Context.Tag("TimesheetRules")<TimesheetRules, {
  isValid: (data: ReadonlyArray<EmployeeTimeSheetEntry>) => Effect.Effect<boolean, TimesheetRulesError>
}>() {}
export class TimesheetRuleContainer extends Context.Tag("TimesheetRuleContainer")<TimesheetRuleContainer, {
  rules: ReadonlySet<TimesheetRules>
  add: (rule: TimesheetRules) => Effect.Effect<void>
  validate: () => Effect.Effect<void>
}>() {}
export function make() {
  return Effect.gen(function*() {
    const rules = new Set<TimesheetRules>()
    const add = (rule: TimesheetRules) => {
      rules.add(rule)
      return Effect.void
    }
    const validate = () => {
      for (const rule of rules) {
        const r = yield* rule.isValid() //doesn't work
        
      }
    }
  })
}
Was this page helpful?