/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../../../lib/primitives.js";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type Team = {
  name: string;
  createdAt: Date;
};

/** @internal */
export const Team$inboundSchema: z.ZodType<Team, z.ZodTypeDef, unknown> = z
  .object({
    name: z.string(),
    created_at: z.string().datetime({ offset: true }).transform(v =>
      new Date(v)
    ),
  }).transform((v) => {
    return remap$(v, {
      "created_at": "createdAt",
    });
  });

export function teamFromJSON(
  jsonString: string,
): SafeParseResult<Team, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Team$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Team' from JSON`,
  );
}
