/** * Copyright (c) 2026, Salesforce, Inc., * All rights reserved. * For full license text, see the LICENSE.txt file */ import { getOrgAuth } from "../lib/auth.js"; import { validateInputValue } from "../lib/validator.js"; import { getSchema } from "../lib/walker.js"; export async function validateInputCommand( orgAlias: string, typeName: string, jsonValue: string, ): Promise { const auth = await getOrgAuth(orgAlias); const schema = getSchema(auth.instanceUrl); let parsed: unknown; try { parsed = JSON.parse(jsonValue); } catch { console.error(`Invalid JSON: ${jsonValue}`); process.exit(1); } const errors = validateInputValue(schema, typeName, parsed); if (errors.length === 0) { console.log(`Valid. All fields and operators match ${typeName} schema.`); } else { console.log(`${errors.length} validation error${errors.length === 1 ? "" : "s"}:`); errors.forEach((e, i) => { console.log(` ${i + 1}. ${e.path ? `${e.path}: ` : ""}${e.message}`); }); process.exit(1); } }