( stringValue: string, schema: PrimitiveSchemaDefinition, )
| 223 | } |
| 224 | |
| 225 | export function validateElicitationInput( |
| 226 | stringValue: string, |
| 227 | schema: PrimitiveSchemaDefinition, |
| 228 | ): ValidationResult { |
| 229 | const zodSchema = getZodSchema(schema) |
| 230 | const parseResult = zodSchema.safeParse(stringValue) |
| 231 | |
| 232 | if (parseResult.success) { |
| 233 | // zodSchema always produces primitive types for elicitation |
| 234 | return { |
| 235 | value: parseResult.data as string | number | boolean, |
| 236 | isValid: true, |
| 237 | } |
| 238 | } |
| 239 | return { |
| 240 | isValid: false, |
| 241 | error: parseResult.error.issues.map(e => e.message).join('; '), |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | const hasStringFormat = ( |
| 246 | schema: PrimitiveSchemaDefinition, |
no test coverage detected