From d31d2e9218524c2d2adb18bc31c24620279f10c5 Mon Sep 17 00:00:00 2001 From: Brook Elgie Date: Fri, 25 Nov 2016 16:02:07 +0000 Subject: [PATCH] [#829] Add validator for Source question This special rule checks that each Source URL is a valid URL for the location quesiton which uses `QuestionFieldSource` question type. --- census/ui_app/validators.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/census/ui_app/validators.js b/census/ui_app/validators.js index 5c33eb60..f8f418a9 100644 --- a/census/ui_app/validators.js +++ b/census/ui_app/validators.js @@ -12,6 +12,17 @@ let validators = { return !validator.isEmpty(value.toString()); }, message: 'Question is required' + }, + sourceIsURL: { + rule: value => { + for (let i = 0; i < value.length; i++) { + if (!validator.isURL(value[i].urlValue)) { + return false; + } + } + return true; + }, + message: 'Each source URL must be a valid URL' } };