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

Migrate SafeApp to zod #1296

Merged
merged 6 commits into from
Mar 13, 2024
Merged

Migrate SafeApp to zod #1296

merged 6 commits into from
Mar 13, 2024

Conversation

hectorgomezv
Copy link
Member

Summary

This migrates the validation of SafeApp to zod.

Changes

  • Removes SafeAppValidator and associated schema.
  • Adds SafeAppSchema and infers type(s) from it.
  • Propagate required changes in codebase.
  • Update associated tests.
  • Changes iconUrl from string to string | null.

@hectorgomezv hectorgomezv self-assigned this Mar 13, 2024
@hectorgomezv hectorgomezv requested a review from a team as a code owner March 13, 2024 11:29
@coveralls
Copy link

coveralls commented Mar 13, 2024

Pull Request Test Coverage Report for Build 8265913486

Details

  • 12 of 12 (100.0%) changed or added relevant lines in 4 files are covered.
  • 17 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.4%) to 93.359%

Files with Coverage Reduction New Missed Lines %
src/routes/transactions/entities/tests/human-description.builder.ts 1 80.0%
src/datasources/locking-api/locking-api.service.ts 1 93.33%
src/routes/recovery/guards/disable-recovery-alerts.guard.ts 2 92.86%
src/routes/locking/locking.controller.ts 2 88.24%
src/routes/recovery/guards/enable-recovery-alerts.guard.ts 2 92.86%
src/domain/locking/locking.repository.ts 4 66.67%
src/routes/locking/locking.service.ts 5 41.3%
Totals Coverage Status
Change from base Build 8263873168: -0.4%
Covered Lines: 6330
Relevant Lines: 6546

💛 - Coveralls

src/domain/safe-apps/entities/schemas/safe-app.schema.ts Outdated Show resolved Hide resolved
tags: z.array(z.string()),
features: z.array(z.string()),
socialProfiles: z.array(SafeAppSocialProfileSchema),
iconUrl: z.string().url().nullish().default(null),
Copy link
Member

Choose a reason for hiding this comment

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

Outside of the scope of this PR but we need add this to the SDK.

@hectorgomezv
Copy link
Member Author

Thanks for the suggestion @iamacook! I've committed it, in fact, I had the exact same code and relaxed the validation later (see this difff) because I'm not sure it makes a lot of sense to validate the accessControl property in the CGW, as its logic is more on the Config Service. Adding a new AccessControl type there will break the validation in the CGW, and I think it shouldn't as the CGW doesn't own the logic for this property.

But I also think your suggestion is right since it should be tackled in a separate PR, and we are purely migrating the validation mechanism here 👍🏻

Thanks again!

@hectorgomezv hectorgomezv merged commit b9386d1 into main Mar 13, 2024
16 checks passed
@hectorgomezv hectorgomezv deleted the zod-safe-apps branch March 13, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants