atlassian / atlassian/better-ajv-errors

More readable errors for patterns

Open
#78 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
245
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm struggling with patterns usage and proper error display.

I would like to validate a range of number values, something like `1024-2048`, and I have a pattern to express allowed number values (values between 1024 and 49151) :
`pattern: "^(102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-3][0-9]{4}|4[0-8][0-9]{3}|490[0-9]{2}|491[0-4][0-9]|4915[01])-(102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-3][0-9]{4}|4[0-8][0-9]{3}|490[0-9]{2}|491[0-4][0-9]|4915[01])$"`

But the output for user is displayed as:

```
07:43:09.693Z - error: PATTERN should match pattern "^(102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-3][0-9]{4}|4[0-8][0-9]{3}|490[0-9]{2}|491[0-4][0-9]|4915[01])-(102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-3][0-9]{4}|4[0-8][0-9]{3}|490[0-9]{2}|491[0-4][0-9]|4915[01])$"
> 4 | "ports": "3000-302"
```

which is valid, but not readable to understand what is a valid input.

I would like to know if there is a way to force a message when an error occurs, for instance to use a description instead of the pattern value, or if any other mechanism exists to provide a more readable output without the need to put logic from error report ?

Thanks for your help !

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue does not name files, tests, or an entry point. Start by locating how better-ajv-errors formats AJV PATTERN validation errors, then review how custom messages or schema descriptions could be supplied; the work is done when the approach and expected readable output are defined and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, json
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.