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