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

Function formatMaxLengthValidatorMessage

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

Source from the content-addressed store, hash-verified

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

Callers 1

string.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected