MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / localValidationError

Function localValidationError

src/lib/errors.ts:229–248  ·  view source on GitHub ↗
(
  field: string,
  reason: string,
  accepted?: unknown,
  kind: 'flag' | 'field' = 'flag',
)

Source from the content-addressed store, hash-verified

227 * flag that doesn't exist in the CLI surface.
228 */
229export function localValidationError(
230 field: string,
231 reason: string,
232 accepted?: unknown,
233 kind: 'flag' | 'field' = 'flag',
234): ApiError {
235 const subject =
236 kind === 'flag'
237 ? `Flag \`--${field.replace(/[A-Z]/g, ch => `-${ch.toLowerCase()}`)}\``
238 : `Field \`${field}\``;
239 return ApiError.fromEnvelope({
240 error: {
241 code: 'VALIDATION_ERROR',
242 message: 'Invalid request.',
243 nextAction: `${subject} is invalid: ${reason}.`,
244 requestId: 'local',
245 details: accepted === undefined ? { field, reason } : { field, reason, accepted },
246 },
247 });
248}
249
250/**
251 * Network/transport failure not associated with a server envelope. Treated

Callers 6

requireStringFunction · 0.70
requireEnumFunction · 0.70
assertIdempotencyKeyFunction · 0.70
requireArrayLengthFunction · 0.70
validatePaginationFlagsFunction · 0.70
errors.test.tsFile · 0.70

Calls 1

fromEnvelopeMethod · 0.80

Tested by

no test coverage detected