Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++
584 B
Raw Blame
import type { Order } from './orders.ts';

export function validateOrders(orders: Order[]): Order[] {
  if (!Array.isArray(orders)) throw new RangeError('orders');
  return orders.map((o) => {
    if (
      !o ||
      typeof o.customer !== 'string' ||
      !o.customer.trim() ||
      !Number.isInteger(o.priceCents) ||
      o.priceCents < 0 ||
      !Number.isInteger(o.quantity) ||
      o.quantity <= 0 ||
      (o.cancelled !== undefined && typeof o.cancelled !== 'boolean')
    )
      throw new RangeError('order');
    return { ...o, customer: o.customer.trim() };
  });
}