Skip to content

Add min, max and length contraints to the GeospatialField#399

Merged
davidjamesstone merged 2 commits into
mainfrom
feature/DF-1084-feature-limits
May 18, 2026
Merged

Add min, max and length contraints to the GeospatialField#399
davidjamesstone merged 2 commits into
mainfrom
feature/DF-1084-feature-limits

Conversation

@davidjamesstone
Copy link
Copy Markdown
Contributor

@davidjamesstone davidjamesstone commented May 15, 2026

Proposed change

Add min, max and exact length schema constraints to the GeospatialField.
Depends on DEFRA/forms-designer#1442

Jira ticket: https://eaflood.atlassian.net/browse/DF-1086

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Misc. (documentation, build updates, etc)

Checklist

  • You have executed this code locally and it performs as expected.
  • You have added tests to verify your code works.
  • You have added code comments and JSDoc, where appropriate.
  • There is no commented-out code.
  • You have added developer docs in README.md and docs/* (where appropriate, e.g. new features).
  • The tests are passing (npm run test).
  • The linting checks are passing (npm run lint).
  • The code has been formatted (npm run format).

@davidjamesstone davidjamesstone force-pushed the feature/DF-1084-feature-limits branch from 56dae24 to d5c86d3 Compare May 18, 2026 12:45

expect(result.error).toBeUndefined()
expect(result.value).toEqual([])
expect(result.value).toBeUndefined()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this correct, or should it be an empty array still?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes that's correct now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I needed to change the behavior slightly because we introduced min/max and when used with optional, there's a bit of a question mark. I decided to make it work like this:

  1. If the field is optional, you don't have to add anything
  2. If the field is optional and has a min/max/length, you don't have to add anything but once you do, they have to also satisfy the min/max limits.

@davidjamesstone davidjamesstone marked this pull request as ready for review May 18, 2026 13:40
@sonarqubecloud
Copy link
Copy Markdown

Comment thread src/server/plugins/engine/components/GeospatialField.test.ts
Comment thread src/server/plugins/engine/components/GeospatialField.test.ts
Comment thread src/server/plugins/engine/components/GeospatialField.test.ts
Comment thread src/server/plugins/engine/components/GeospatialField.test.ts
Comment thread src/server/plugins/engine/components/GeospatialField.test.ts
Comment thread src/server/plugins/engine/components/GeospatialField.test.ts
Comment thread src/server/plugins/engine/components/GeospatialField.test.ts
@davidjamesstone
Copy link
Copy Markdown
Contributor Author

Regarding the singular/plural in the error messages, we agreed to pick this up in a separate ticket. These messages come from joi and will need addressing in other components like File upload and Checkboxes.

@davidjamesstone davidjamesstone merged commit 4d33838 into main May 18, 2026
32 checks passed
@davidjamesstone davidjamesstone deleted the feature/DF-1084-feature-limits branch May 18, 2026 13:52
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.

2 participants