| 733 | module.exports = SchemaString; |
| 734 | |
| 735 | function formatMaxLengthValidatorMessage(msg) { |
| 736 | return function(props, doc) { |
| 737 | if (typeof msg === 'function') { |
| 738 | return MongooseError.ValidatorError.prototype.formatMessage(msg, props, doc); |
| 739 | } |
| 740 | |
| 741 | if (typeof msg === 'string' && typeof props.value === 'string' && props.value.length > 30) { |
| 742 | props = Object.assign({}, props, { |
| 743 | value: props.value.slice(0, 30) + '...' |
| 744 | }); |
| 745 | } |
| 746 | return MongooseError.ValidatorError.prototype.formatMessage(msg, props, doc); |
| 747 | }; |
| 748 | } |