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

chore: use ajv standalone validation code #258

Merged
merged 6 commits into from
Oct 27, 2023
Merged

Conversation

zixiang2018
Copy link
Contributor

@zixiang2018 zixiang2018 commented Oct 26, 2023

Context

What this PR does

  • add compilation of schema in postInstall.js
    • there are two types of validation modes in our codebase - strict and non-strict; hence there are two compiled javascript functions file which caters for both scenarios.
  • removed compilation of schema during runtime to avoid the need for unsafe-eval on Verifiers UI
  • make use of the compiled schema javascript functions for validation
  • modified tsconfig.json to allowJs imports (to import the compiled files)

if (!schema) throw new Error(`Could not find ${key} schema`);
return schema;
return schema as AnyValidateFunction;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between AnyValidateFunction vs ValidateFunction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh AnyValidateFunction caters for async validations. Just realised we dont use it in our validation, Ill revert to using ValidateFunction like before!

@zixiang2018 zixiang2018 requested a review from HJunyuan October 27, 2023 01:17
@zixiang2018 zixiang2018 merged commit 2a69683 into master Oct 27, 2023
8 checks passed
@github-actions
Copy link

🎉 This PR is included in version 6.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

zixiang2018 added a commit that referenced this pull request Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants