From 4bde2f78944c5bad28071e807d1ac3d459374dac Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 27 Apr 2016 23:07:06 +0300 Subject: [PATCH] Render max/minCharacters (#42) --- lib/components/JsonSchema/json-schema.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 56facedd98..6e5687df9f 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -225,5 +225,22 @@ const injectors = { injectTo._range = range; } } + }, + string: { + check: propertySchema => (propertySchema.type === 'string'), + inject: (injectTo, propertySchema = injectTo) => { + var range; + if (propertySchema.minLength && propertySchema.maxLength) { + range = `[ ${propertySchema.minLength} .. ${propertySchema.maxLength} ]`; + } else if (propertySchema.maxLength) { + range = '<= ' + propertySchema.maxLength; + } else if (propertySchema.minimum) { + range = '>= ' + propertySchema.minLength; + } + + if (range) { + injectTo._range = range + ' characters'; + } + } } };