(_mapper)
| 29132 | return this.issues; |
| 29133 | } |
| 29134 | format(_mapper) { |
| 29135 | const mapper = _mapper || function(issue) { |
| 29136 | return issue.message; |
| 29137 | }; |
| 29138 | const fieldErrors = { _errors: [] }; |
| 29139 | const processError = (error) => { |
| 29140 | for (const issue of error.issues) { |
| 29141 | if (issue.code === "invalid_union") { |
| 29142 | issue.unionErrors.map(processError); |
| 29143 | } else if (issue.code === "invalid_return_type") { |
| 29144 | processError(issue.returnTypeError); |
| 29145 | } else if (issue.code === "invalid_arguments") { |
| 29146 | processError(issue.argumentsError); |
| 29147 | } else if (issue.path.length === 0) { |
| 29148 | fieldErrors._errors.push(mapper(issue)); |
| 29149 | } else { |
| 29150 | let curr = fieldErrors; |
| 29151 | let i3 = 0; |
| 29152 | while (i3 < issue.path.length) { |
| 29153 | const el = issue.path[i3]; |
| 29154 | const terminal = i3 === issue.path.length - 1; |
| 29155 | if (!terminal) { |
| 29156 | curr[el] = curr[el] || { _errors: [] }; |
| 29157 | } else { |
| 29158 | curr[el] = curr[el] || { _errors: [] }; |
| 29159 | curr[el]._errors.push(mapper(issue)); |
| 29160 | } |
| 29161 | curr = curr[el]; |
| 29162 | i3++; |
| 29163 | } |
| 29164 | } |
| 29165 | } |
| 29166 | }; |
| 29167 | processError(this); |
| 29168 | return fieldErrors; |
| 29169 | } |
| 29170 | static assert(value) { |
| 29171 | if (!(value instanceof _ZodError)) { |
| 29172 | throw new Error(`Not a ZodError: ${value}`); |
no outgoing calls
no test coverage detected