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

Throw ConfigError when component configs are invalid #4176

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

domoscargin
Copy link
Contributor

@domoscargin domoscargin commented Sep 5, 2023

Closes #4037

What

I've got two approaches here:

Validate within the component class

At the moment, we only need this validation on Character Count, so we could just do a specific validation in that class. Might be good enough for now.

Use a schema

It'd be nice to just use something like AJV and validate a schema, but that'd add weight to our code, so I've implemented a custom validation method on the base component that we can build on as necessary.

It'd also be nice to somehow use our YAML (or compiled JSON fixtures) here, but that's a lot trickier to unpick than is required for this work (for example: how to separate out nunjucks and JS properties, how to document more complex rules like anyOf, etc).


Update: We've gone with the schema approach and loosely followed:
https://ajv.js.org/packages/ajv-errors.html#single-message

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4176 September 5, 2023 09:04 Inactive
@domoscargin domoscargin added this to the v5.0 milestone Sep 5, 2023
@domoscargin domoscargin force-pushed the bk-illegal-config-error branch from 14bdb89 to 3cd4098 Compare September 5, 2023 09:21
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4176 September 5, 2023 09:21 Inactive
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

📋 Stats

File sizes

File Size
dist/govuk-frontend-4.6.0.min.css 118.07 KiB
dist/govuk-frontend-4.6.0.min.js 47.1 KiB
dist/govuk-frontend-ie8-4.6.0.min.css 79.27 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 73.57 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 69.08 KiB
packages/govuk-frontend/dist/govuk/all.mjs 3.84 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 35.82 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.83 KiB

Modules

File Size
all.mjs 65.19 KiB
components/accordion/accordion.mjs 20.86 KiB
components/button/button.mjs 3.67 KiB
components/character-count/character-count.mjs 20.6 KiB
components/checkboxes/checkboxes.mjs 4.37 KiB
components/error-summary/error-summary.mjs 4.96 KiB
components/exit-this-page/exit-this-page.mjs 15.42 KiB
components/header/header.mjs 2.3 KiB
components/notification-banner/notification-banner.mjs 3.5 KiB
components/radios/radios.mjs 3.37 KiB
components/skip-link/skip-link.mjs 2.67 KiB
components/tabs/tabs.mjs 8.04 KiB

View stats and visualisations on the review app


Action run for 55a54b7

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4176 September 6, 2023 09:42 Inactive
@domoscargin domoscargin force-pushed the bk-illegal-config-error branch from 80881a5 to cc5c232 Compare September 6, 2023 12:47
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4176 September 6, 2023 12:50 Inactive
@domoscargin domoscargin force-pushed the bk-illegal-config-error branch from 4c87404 to 349665f Compare September 6, 2023 12:56
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4176 September 6, 2023 12:56 Inactive
@domoscargin domoscargin force-pushed the bk-illegal-config-error branch from 349665f to ca48e66 Compare September 6, 2023 13:53
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4176 September 6, 2023 13:53 Inactive
@domoscargin domoscargin force-pushed the bk-illegal-config-error branch from ca48e66 to abefc27 Compare September 7, 2023 14:54
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4176 September 7, 2023 14:55 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Throw errors if JavaScript components receive an illegal configuration
4 participants