MCPcopy Create free account
hub / github.com/Automattic/mongoose / formatMaxLengthValidatorMessage

Function formatMaxLengthValidatorMessage

lib/schema/string.js:735–748  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

733module.exports = SchemaString;
734
735function 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}

Callers 1

string.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected