kleros-v2 icon indicating copy to clipboard operation
kleros-v2 copied to clipboard

feat: use zod directly for validating dispute templates

Open kemuru opened this issue 1 year ago • 6 comments

This is a WIP:

For now, only escrow v2 and curate v2 disputes render, and all the other ones don't since they don't adhere to the validations I put (which are provisional ones). I think we need to decide on a more robust dispute template specification (which fields exactly the templates will have), and use that dispute template everywhere (on the Dispute Resolver, and on the arbitrables' dispute templates). Also document this once its done so the integrations are very easy.

I've put some logs detailing exactly why the template validation failed in case it did.

Summary by CodeRabbit

  • New Features

    • Enhanced validation with new isHexAddress and isHexId functions.
  • Improvements

    • Made several fields optional in schemas to increase flexibility (e.g., attachment, metadata, lang).
  • Refactor

    • Updated validation logic to use DisputeDetailsSchema for improved consistency and error handling.

PR-Codex overview

This PR updates dispute details validation by replacing DisputeDetailsValidator with DisputeDetailsSchema for better error handling and adds optional fields to various schemas.

Detailed summary

  • Replaced DisputeDetailsValidator with DisputeDetailsSchema for validation
  • Added optional fields to AnswerSchema and AliasSchema
  • Made attachment, metadata, arbitrableAddress, arbitratorAddress, lang, specification optional in DisputeDetailsSchema

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

kemuru avatar Jun 28 '24 18:06 kemuru