mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-04 02:01:58 -05:00
🐛 Fixed validation error when creating 0% offer (#16803)
closes https://github.com/TryGhost/Team/issues/3073 Fixed validation error when creating 0% offer. Issue was occurring due to a falsy check on the offer value. Have resolved by having a more strict check on the offer value based on the possible empty value it can be - If creating a new offer without providing an offer value, the value will be `undefined`. If supplying an offer value, then removing the offer value, the value will be an empty string. This check prevents `0` being classed as an invalid value.
This commit is contained in:
parent
965e9700a0
commit
ef0b863c2b
1 changed files with 2 additions and 6 deletions
|
@ -16,12 +16,8 @@ export default BaseValidator.create({
|
||||||
},
|
},
|
||||||
|
|
||||||
amount(model) {
|
amount(model) {
|
||||||
if (!model.amount) {
|
if (model.amount === '' || model.amount === undefined) {
|
||||||
if (model.type === 'trial') {
|
model.errors.add('amount', 'Please enter the amount.');
|
||||||
model.errors.add('amount', 'Free trial must be at least 1 day.');
|
|
||||||
} else {
|
|
||||||
model.errors.add('amount', 'Please enter the amount.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.invalidate();
|
return this.invalidate();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue