From 52770dc79ca10652cafaffe5a285a84e2b78984e Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Wed, 31 Aug 2016 10:17:46 -0300 Subject: [PATCH] LT-67: Validating server information with its schema --- .../serverInformationForm/serverInformationForm.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.js b/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.js index 41cfd26c6..1ff70c6c1 100644 --- a/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.js +++ b/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.js @@ -53,7 +53,16 @@ Template.serverInformationForm.onRendered(() => { Template.serverInformationForm.events({ submit(event, instance) { event.preventDefault(); - var formData = instance.data.form.value(); + + // Stop here if the form validation fails + if (!instance.data.form.validate()) { + return; + } + + // Get the current form data + const formData = instance.data.form.value(); + + // Call the save method Meteor.call('serverSave', formData, function(error) { if (error) { // TODO: check for errors: not-authorized, data-write