customproperty.ts•2 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type CustomProperty = {
/**
* The name of the custom property of this type.
*/
name: string;
/**
* An array of values for the custom property data to associate with this flag.
*/
value: Array<string>;
};
/** @internal */
export const CustomProperty$inboundSchema: z.ZodType<
CustomProperty,
z.ZodTypeDef,
unknown
> = z.object({
name: z.string(),
value: z.array(z.string()),
});
/** @internal */
export type CustomProperty$Outbound = {
name: string;
value: Array<string>;
};
/** @internal */
export const CustomProperty$outboundSchema: z.ZodType<
CustomProperty$Outbound,
z.ZodTypeDef,
CustomProperty
> = z.object({
name: z.string(),
value: z.array(z.string()),
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace CustomProperty$ {
/** @deprecated use `CustomProperty$inboundSchema` instead. */
export const inboundSchema = CustomProperty$inboundSchema;
/** @deprecated use `CustomProperty$outboundSchema` instead. */
export const outboundSchema = CustomProperty$outboundSchema;
/** @deprecated use `CustomProperty$Outbound` instead. */
export type Outbound = CustomProperty$Outbound;
}
export function customPropertyToJSON(customProperty: CustomProperty): string {
return JSON.stringify(CustomProperty$outboundSchema.parse(customProperty));
}
export function customPropertyFromJSON(
jsonString: string,
): SafeParseResult<CustomProperty, SDKValidationError> {
return safeParse(
jsonString,
(x) => CustomProperty$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CustomProperty' from JSON`,
);
}