cds-snc / cds-snc/platform-forms-client

Advanced template validation

Open
#7,902 1 comment 1 reaction 1 assignee Claimed by @timarney View on GitHub
app enhancement incident tech debt testing
Dominant language
TypeScript
Stars
46
Forks
16
Avg merge
1d 8h
Merged PRs (30d)
85

Description

## Summary

We need ensure when templates are imported, exported saved can be validated and "auto-fixed" where possible.

Template should not land in the database unless we know they are valid and won't cause issues.

We currently have validate template schema in place but it doesn't do enough. We need a more granular validation.

## Goals
This code should be portable across repos and should be as easy to read and maintain as possible.

Potentially this could also be used by AI for helping to spot / help describe template shape and detect issues. We could also create a page for support to be able to paste a template and help validate it. Another use case is being able to paste template json to either fully replace or paste multiple form elements.

Bottom line we need to know incoming JSON is valid and matches our expectations.

## Starter exercise

I would propose that it would likely be a good exercise to "explain the template parts" in plain text as if it's written for a new person joining the team (in any role).

## Prior Art

**Example Rules:**
- Contains expected nodes
- Start, Review and End exists and have proper next actions
- name, titleEn, titleFr , elements array exists
- layout exists and contains valid elements
- groupsLayout exists and is valid
- elements array is valid
- element rules are valid - rules are clean
- no stray elements exists

**See existing:**

- resetReviewEndNextAction
- cleanFormStructure
- hasCleanedRules
- cleanElements
- cleanElementRules
- autoFlowFormIfPossible

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.