From 862fa88e99174d3c853028f126730860074b0dee Mon Sep 17 00:00:00 2001 From: qige2016 <286882998@qq.com> Date: Sat, 13 Jun 2020 23:35:09 +0800 Subject: [PATCH 1/2] fix[notEmpty]: set trim => trim() --- plop-templates/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plop-templates/utils.js b/plop-templates/utils.js index 0310ca02b30..5196a1a8105 100644 --- a/plop-templates/utils.js +++ b/plop-templates/utils.js @@ -1,6 +1,6 @@ exports.notEmpty = name => { return v => { - if (!v || v.trim === '') { + if (!v || v.trim() === '') { return `${name} is required` } else { return true From 617faf705220ac1fdc53053564de649723f58045 Mon Sep 17 00:00:00 2001 From: qige2016 <286882998@qq.com> Date: Mon, 15 Jun 2020 10:27:06 +0800 Subject: [PATCH 2/2] refactor: change if...else to ternary operator --- plop-templates/utils.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plop-templates/utils.js b/plop-templates/utils.js index 5196a1a8105..04987539799 100644 --- a/plop-templates/utils.js +++ b/plop-templates/utils.js @@ -1,9 +1,2 @@ -exports.notEmpty = name => { - return v => { - if (!v || v.trim() === '') { - return `${name} is required` - } else { - return true - } - } -} +exports.notEmpty = name => v => + !v || v.trim() === '' ? `${name} is required` : true