scottohara / loot

An implementation of some of the core MS Money features in Ruby on Rails
MIT License
4 stars 3 forks source link

Required currency field validation not enforced #184

Open scottohara opened 3 years ago

scottohara commented 3 years ago

For any required fields that have the og-currency-input directive, when the bound model value (e.g. this.transaction.amount) is undefined, the UI shows $0.00 which circumvents the required form validation for that field.

Typically this isn't a problem, because it is unusual to have, for example, a transaction with a zero amount.

The reason it came up is that for a SecurityInvestment transaction (buy/sell), where there is no commission, the UI defaults the commission field to $0.00, but when the transaction JSON is posted to the server, there is validation that checks that amount === price * quantity + commission.

This was failing because it wasn't expecting commission to be undefined.