diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 56facedd..6e5687df 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'; + } + } } };