From 758ac51c61661499fce5359576c14529530efe2b Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Fri, 24 Jun 2016 11:17:07 -0400 Subject: [PATCH] [added] string.ensure Coerce empty values to empty strings --- src/string.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/string.js b/src/string.js index d4eb0a7f4..7baa5e2a1 100644 --- a/src/string.js +++ b/src/string.js @@ -88,6 +88,12 @@ inherits(StringSchema, MixedSchema, { }, //-- transforms -- + ensure() { + return this + .default('') + .transform(val => val === null ? '' : val) + }, + trim(msg) { msg = msg || locale.trim