Skip to content

Commit

Permalink
Validations min/max count: allow zeros (backward compatibility) (#3714)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Ricci <[email protected]>
  • Loading branch information
SteRiccio and SteRiccio authored Jan 24, 2025
1 parent 662ab03 commit 4144a3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const validateCountProp =
const count = Validator.getProp(propName)(item)
return Array.isArray(count)
? NodeDefExpressionsValidator.validate(survey, nodeDef, dependencyType)
: Validator.validatePositiveNumber(errorKey)(propName, item)
: Validator.validatePositiveOrZeroNumber(errorKey)(propName, item)
}

export const validate = async (survey, nodeDef) => {
Expand Down
4 changes: 3 additions & 1 deletion webapp/components/survey/NodeDefDetails/ValidationsProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { State } from './store'

const countTypes = [NodeDefValidations.keys.min, NodeDefValidations.keys.max]

const countPropNumberFormat = NumberFormats.integer({ allowNegative: false })

const CountProp = (props) => {
const { Actions, countType, nodeDef, nodeDefUuidContext, readOnly, state } = props

Expand Down Expand Up @@ -65,7 +67,7 @@ const CountProp = (props) => {
excludeCurrentNodeDef
valueTypeSelection
determineValueType={determineValueType}
valueConstantEditorNumberFormat={NumberFormats.integer()}
valueConstantEditorNumberFormat={countPropNumberFormat}
/>
</div>
)
Expand Down

0 comments on commit 4144a3c

Please sign in to comment.