Skip to content

Commit

Permalink
Allowing maxCount: 1 in RepeatingGroup (#2757)
Browse files Browse the repository at this point in the history
Co-authored-by: Ole Martin Handeland <[email protected]>
  • Loading branch information
olemartinorg and Ole Martin Handeland authored Nov 26, 2024
1 parent 780cc1c commit f60c181
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/features/devtools/utils/layoutSchemaValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ export function formatLayoutSchemaValidationError(error: DefinedError): string |
return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er ikke av typen \`${
error.params.type
}\` ${canBeExpression ? 'eller et uttrykk' : ''}`;
case 'minimum':
if (error.params.comparison === '>=') {
return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er mindre enn minimumsverdien ${
error.params.limit
}`;
}

return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er mindre enn eller lik minimumsverdien ${
error.params.limit
}`;
case 'maximum':
if (error.params.comparison === '<=') {
return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er større enn maksimumsverdien ${
error.params.limit
}`;
}

return `Ugyldig verdi for egenskapen ${propertyString}, verdien \`${error.data}\` er større enn eller lik maksimumsverdien ${
error.params.limit
}`;
case 'if':
case 'anyOf':
case 'oneOf':
Expand Down
5 changes: 3 additions & 2 deletions src/layout/RepeatingGroup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const Config = new CG.component({
'maxCount',
new CG.int()
.optional()
.setMin(2)
.setMin(1)
.setTitle('Max number of rows')
.setDescription('Maximum number of rows that can be added.'),
),
Expand All @@ -265,7 +265,8 @@ export const Config = new CG.component({
new CG.prop(
'minCount',
new CG.int()
.optional()
.setMin(0)
.optional({ default: 0 })
.setTitle('Min number of rows')
.setDescription(
'Minimum number of rows that should be added. If the user has not added enough rows, ' +
Expand Down

0 comments on commit f60c181

Please sign in to comment.