232
const enumDynamic = schema.enumDynamic === true;
233
return (value, path) => {
235
>
case 'string': if (typeof value !== 'string') { throw invalidParams(path, 'string', value); } break;
236
>
case 'number': if (typeof value !== 'number') { throw invalidParams(path, 'number', value); } break;
237
>
case 'boolean': if (typeof value !== 'boolean') { throw invalidParams(path, 'boolean', value); } break;
238
>
case 'array': if (!Array.isArray(value)) { throw invalidParams(path, 'array', value); } break;
239
>
case 'object': if (typeof value !== 'object' || value === null || Array.isArray(value)) { throw invalidParams(path, 'object', value); } break;
240
>
}
241
>
if (schema.enum && !enumDynamic && !schema.enum.includes(value as string)) {
242
throw new ProtocolError(JsonRpcErrorCodes.InvalidParams, `Invalid value at '${path || '<root>'}': ${safeStringify(value)} is not one of [${schema.enum.map(v => JSON.stringify(v)).join(', ')}]`);
243
}
245
}
246