Merge pull request #525 from gradido/fix-amount-input-field

fix: Validation of GDD Send Amount Field
This commit is contained in:
Moriz Wahl 2021-06-14 15:47:39 +02:00 committed by GitHub
commit 53eac33a16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,10 +54,14 @@ extend('max', {
extend('gddSendAmount', {
validate(value, { min, max }) {
value = value.replace(',', '.')
return value.match(/^[0-9]+(\.[0-9]{1,2})?$/) && Number(value) >= min && Number(value) <= max
return value.match(/^[0-9]+(\.[0-9]{0,2})?$/) && Number(value) >= min && Number(value) <= max
},
params: ['min', 'max'],
message: (_, values) => i18n.t('form.validation.gddSendAmount', values),
message: (_, values) => {
values.min = i18n.n(values.min)
values.max = i18n.n(values.max)
return i18n.t('form.validation.gddSendAmount', values)
},
})
// eslint-disable-next-line camelcase