Repository navigation
fix(concerto-cto): reject duplicate validators instead of silently keeping the last - #1314
Merged
mttrbrts merged 1 commit intoSep 3, 2026
Conversation
…eping the last The any-order validator collection introduced in accordproject#1305 buckets validators by $class with plain assignment, so regex=/a/ regex=/b/ now parses and silently drops /a/. The same applies to length, range and size, on both fields and scalars; before accordproject#1305 the grammar rejected all of these. A modeler's constraint being silently discarded weakens validation. The grammar initializer gains a bucketValidators helper that raises a located 'Duplicate <kind> validator' error on a repeat, used by all five reducer rules. src/parser.js regenerated with npm run parser, matching the convention of committing the generated parser. Seven tests added covering duplicate regex, length, range (Integer, Double, Long) and size on fields plus regex on a scalar; all fail on the unfixed grammar and every any-order valid case from accordproject#1305 still parses. Signed-off-by: rajanpanth <rajan.pantha@samriddhicollege.edu.np>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change restores correct duplicate-validator rejection with targeted tests and includes the regenerated parser to match the updated grammar.
Pull request overview
Restores the pre-#1305 behavior of rejecting duplicate validators (regex/length/range/size) during parsing, preventing silent “last-wins” constraint weakening while keeping validator ordering flexible.
Changes:
- Added
bucketValidatorshelper to detect and throw on duplicate validator kinds during reduction. - Updated validator collection reducers to use
bucketValidatorsinstead of last-wins assignment. - Added regression tests for duplicate validators and regenerated the committed parser output.
File summaries
| File | Description |
|---|---|
| packages/concerto-cto/test/parserMain.js | Adds regression tests ensuring duplicate validators are rejected. |
| packages/concerto-cto/src/parser.pegjs | Introduces bucketValidators and applies it to validator-bucketing grammar rules. |
| packages/concerto-cto/src/parser.js | Regenerated parser output reflecting the updated grammar logic. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mttrbrts
approved these changes
Sep 3, 2026
Member
There was a problem hiding this comment.
You're on a roll @rajanpanth . Thanks!
cc: @muhabdulkadir
mttrbrts
enabled auto-merge (squash)
September 3, 2026 09:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
(validator)*and bucketing by$classwith plain assignment. A repeated validator of the same kind now parses and silently keeps only the last one:regex=/a/ regex=/b/drops/a/,range=[0,10] range=[500,600]keeps only[500,600], and the same holds forlengthandsize, on both fields and scalars. Before feat(concerto-cto): allow validators in any order in field declarations #1305 the grammar rejected all of these, and the metamodel has exactly one slot per validator kind, so last-wins silently discards a modeler's constraint and weakens validation. feat(concerto-cto): allow validators in any order in field declarations #1305's stated intent was ordering flexibility only.bucketValidators(items, kindByClass)helper that raises a located peggyerror('Duplicate <kind> validator'), surfacing as a normalParseException; the five reducer rules use it.src/parser.jsis regenerated vianpm run parser, matching the convention of committing the generated parser.Executed comparison, old parser (HEAD~1 grammar) vs current main:
Tests
Seven cases added under the
validator orderingdescribe intest/parserMain.js: duplicate regex and length on a String field, duplicate range on Integer, Double and Long, duplicate size on an array, and duplicate regex on a scalar. With the grammar and generated parser reverted and the tests kept, all seven fail withexpected [Function] to throw an error; restored, the concerto-cto suite passes 177/177 and every any-order valid case from #1305 still parses. eslint clean.