Skip to content

Commit

Permalink
Render max/minCharacters (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Apr 27, 2016
1 parent 4c92368 commit 4bde2f7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/components/JsonSchema/json-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
}
};

0 comments on commit 4bde2f7

Please sign in to comment.