(issue: ZodIssue, placeholderFields: Set<string>)
| 152 | } |
| 153 | |
| 154 | function isPlaceholderIssue(issue: ZodIssue, placeholderFields: Set<string>): boolean { |
| 155 | const field = issue.path[0]; |
| 156 | if (typeof field !== 'string') { |
| 157 | return false; |
| 158 | } |
| 159 | |
| 160 | if (!placeholderFields.has(field)) { |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | switch (issue.code) { |
| 165 | case 'invalid_type': |
| 166 | return true; |
| 167 | case 'invalid_format': |
| 168 | return true; |
| 169 | case 'too_small': |
| 170 | return true; |
| 171 | case 'too_big': |
| 172 | return true; |
| 173 | case 'invalid_value': |
| 174 | // Enum/literal validation fails on placeholder objects with missing fields |
| 175 | // The actual value from upstream will have the correct enum value at runtime |
| 176 | return true; |
| 177 | case 'custom': |
| 178 | // Custom validations (from .refine()) fail on placeholders but will pass at runtime |
| 179 | // when the actual value comes from the connected edge |
| 180 | return true; |
| 181 | case 'invalid_union': |
| 182 | if ('unionErrors' in issue) { |
| 183 | const unionIssue = issue as ZodIssue & { unionErrors: ZodError[] }; |
| 184 | return unionIssue.unionErrors.every((variant: ZodError) => |
| 185 | variant.issues.every((inner) => inner.code === 'invalid_type'), |
| 186 | ); |
| 187 | } |
| 188 | return false; |
| 189 | default: |
| 190 | return false; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * Validate secret parameter references |
no test coverage detected