From 4fdbc5b4cbc7c42a1596dbe02e17e8fd95621211 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Wed, 12 Jun 2019 12:28:00 -0400 Subject: [PATCH 1/2] Only show first error message on application form --- js/components/forms/new_application.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/components/forms/new_application.js b/js/components/forms/new_application.js index df7bc4e9..c40839f6 100644 --- a/js/components/forms/new_application.js +++ b/js/components/forms/new_application.js @@ -1,5 +1,6 @@ import FormMixin from '../../mixins/form' import textinput from '../text_input' +import * as R from "ramda" const createEnvironment = name => ({ name }) @@ -34,14 +35,14 @@ export default { func: this.hasEnvironments, message: 'Provide at least one environment name.', }, - { - func: this.envNamesAreUnique, - message: 'Environment names must be unique.', - }, { func: this.environmentsHaveNames, message: 'Environment names cannot be empty.', }, + { + func: this.envNamesAreUnique, + message: 'Environment names must be unique.', + }, ], errors: [], environments, @@ -66,13 +67,12 @@ export default { }, validate: function() { - this.errors = this.validations - .map(validation => { - if (!validation.func()) { - return validation.message - } - }) - .filter(Boolean) + // Only take first error message + this.errors = R.pipe( + R.map((validation) => !validation.func() ? validation.message : undefined), + R.filter(Boolean), + R.take(1) + )(this.validations) }, hasEnvironments: function() { From 6835f149c333be9ed8d8f25142a0964ced6d3bb7 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Wed, 12 Jun 2019 14:31:44 -0400 Subject: [PATCH 2/2] Formatting --- js/components/forms/new_application.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/components/forms/new_application.js b/js/components/forms/new_application.js index c40839f6..b695bd6b 100644 --- a/js/components/forms/new_application.js +++ b/js/components/forms/new_application.js @@ -1,6 +1,6 @@ import FormMixin from '../../mixins/form' import textinput from '../text_input' -import * as R from "ramda" +import * as R from 'ramda' const createEnvironment = name => ({ name }) @@ -69,7 +69,9 @@ export default { validate: function() { // Only take first error message this.errors = R.pipe( - R.map((validation) => !validation.func() ? validation.message : undefined), + R.map(validation => + !validation.func() ? validation.message : undefined + ), R.filter(Boolean), R.take(1) )(this.validations)