giffer

Create .gif images from sites like youtube.com
Log | Files | Refs | LICENSE

commit bb77f210bebd6ee0496f2afcb5d4abce995dd155
parent e060d54aecbc3231a10c0d82c74c8cf32abfc7fd
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date:   Thu, 15 Nov 2018 15:37:31 +1300

[~] Better form field validation.

Diffstat:
Mcmd/desktop/ui/src/App.vue | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/cmd/desktop/ui/src/App.vue b/cmd/desktop/ui/src/App.vue @@ -124,17 +124,18 @@ export default { methods: { submit() { this.loading = true - // FIXME(jfm): Validate form data the Vue-idiomatic way. - this.form.keys().forEach(v => { - try { - this.$set(this.form, v, Number(this.form[v])) - } catch(err) { - this.$set(this.form, v, 0) + let numbers = ["start", "end", "fps", "width", "height", "quality"] + numbers.forEach(v => { + let n = Number(this.form[v]) + if (n === NaN) { this.pushMessage({ name: "Form Validation", description: `${v} should be a number, got ${typeof this.form[v]}`, isError: true, }) + this.$set(this.form, v, 0) + } else { + this.$set(this.form, v, n) } }) axios.post("gifify", this.form)