Bladeren bron

Validate loan fields

master
Immanuel Onyeka 1 jaar geleden
bovenliggende
commit
090ab9f565
4 gewijzigde bestanden met toevoegingen van 19 en 6 verwijderingen
  1. +1
    -1
      assets/main.css
  2. +1
    -1
      components/login.vue
  3. +16
    -4
      components/new.vue
  4. +1
    -0
      skouter.go

+ 1
- 1
assets/main.css Bestand weergeven

@@ -86,7 +86,7 @@ menu.sidebar {
gap: 20px;
}

div.errors {
ul.errors {
color: var(--text-important);
margin: 20px 0;
min-height: 40px 0;


+ 1
- 1
components/login.vue Bestand weergeven

@@ -41,4 +41,4 @@ export default {
return { email: "", password: "", error: ""}
},
}
</script>
</script>

+ 16
- 4
components/new.vue Bestand weergeven

@@ -173,9 +173,9 @@ selected="estimate.transaction == 1">

<button @click="generate">Generate</button>

<div class="errors">
<span v-for="e in errors">{{e}}</span>
</div>
<ul class="errors">
<li v-for="e in errors">{{e}}</li>
</ul>

</section>

@@ -283,7 +283,7 @@ function setLtv(e) {
loan.amount = (ltv / 100 * this.estimate.price).toFixed(2)
}

// Changes loan.amount's <input> and data() values, then syncs with data.ltv
// Changes loan.amount\'s <input> and data() values, then syncs with data.ltv
function setAmount(e) {
let amount = strip(e)
let loan = this.loans[this.sel]
@@ -356,6 +356,18 @@ function validate() {
} else if (!estimate.mIncome) {
errors.push("Missing monthly income.")
}
estimate.loans.forEach(l => {
if (errors.length) return

if (!l.amount) {
errors.push("Loan amount cannot be zero")
} else if (!l.interest) {
errors.push("Interest rate cannot be zero")
} else if (!l.term) {
errors.push("Loan term cannot be zero")
}
})

return errors
}


+ 1
- 0
skouter.go Bestand weergeven

@@ -880,6 +880,7 @@ func api(w http.ResponseWriter, r *http.Request) {
panic(err)
// maybe os.Exit(1) instead
}
switch {
case match(p, "/api/login", &args) &&
r.Method == http.MethodPost:


Laden…
Annuleren
Opslaan