castore icon indicating copy to clipboard operation
castore copied to clipboard

feature: validate event input

Open pmilliotte opened this issue 2 years ago â€ĸ 1 comments

Description đŸĻĢ

Add optional validation of an event input, and implement input validation for ZodEventTypes

Type of change 📝

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

How Has This Been Tested? 🧑‍đŸ”Ŧ

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [ ] Test A
  • [ ] Test B

Test Configuration: 🔧

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist: ✅

  • [ ] My code follows the style guidelines of this project
  • [ ] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] My changes generate no new warnings
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] New and existing unit tests pass locally with my changes
  • [ ] Any dependent changes have been merged and published in downstream modules

pmilliotte avatar Dec 01 '23 13:12 pmilliotte

If this is ever going to be picked up, please consider allowing the validate method to also return a Promise. At least for standard-schema support it would be extremely helpful if async results were supported out of the box, and would not have to be handled by throwing an exception.

Given that validateEventDetail is called in pushEvent which is async anyway, this should hopefully not a major issue. (Not sure how well it would work with groupEvent, which does not yet seem to be considered in this draft... 😟)

EDIT: In standard-schema, the validate method is defined like this:

    readonly validate: (
      value: unknown
    ) => Result<Output> | Promise<Result<Output>>;

oxc avatar Oct 14 '25 15:10 oxc