|
12345678910111213141516171819202122232425262728293031323334353637 |
- 'use strict';
-
- const CastError = require('../error/cast');
-
-
-
- module.exports = function castString(value, path) {
-
- if (value == null) {
- return value;
- }
-
-
- if (value._id && typeof value._id === 'string') {
- return value._id;
- }
-
-
-
-
- if (value.toString &&
- value.toString !== Object.prototype.toString &&
- !Array.isArray(value)) {
- return value.toString();
- }
-
- throw new CastError('string', value, path);
- };
|