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

Function formatMaxLengthValidatorMessage

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

Source from the content-addressed store, hash-verified

737module.exports = SchemaString;
738
739function 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}

Callers 1

string.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected