diff --git a/src/index.ts b/src/index.ts index ce13190..0dcfb70 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,12 +23,12 @@ const apiValidateWithSchema = ( /** * Parse the body of a `h3` event. * - * Cookies are part of the HTTP standard and may be send with a request. + * The body is part of the HTTP standard and may be sent with a request. * * @param {H3Event} event - Input to parse using the passed `schema` - * @param {ZodSchema} schema - Error code of error if parsing fails - * @param {string} [errorCode=422] - Optional error message if parsing fails - * @param {string} [errorMessage="Data parsing failed"] - Optional error message if parsing fails + * @param {ZodSchema} schema - Zod Schema to parse the body with + * @param {string} [errorCode=422] - Error code of error if parsing fails + * @param {string} [errorMessage="Body parsing failed"] - Optional error message if parsing fails */ async function parseBodyAs(event: H3Event, schema: ZodSchema, errorCode = 422, errorMessage = "Body parsing failed") { const data = await readBody(event) @@ -41,9 +41,9 @@ async function parseBodyAs(event: H3Event, schem * For example `/[test].get.ts` binds the parameter `test` to a value, for example `/1` then results in `test = 1` * * @param {H3Event} event - Input to parse using the passed `schema` - * @param {ZodSchema} schema - Error code of error if parsing fails - * @param {string} [errorCode=422] - Optional error message if parsing fails - * @param {string} [errorMessage="Data parsing failed"] - Optional error message if parsing fails + * @param {ZodSchema} schema - Zod Schema to parse parameters with + * @param {string} [errorCode=422] - Error code of error if parsing fails + * @param {string} [errorMessage="Parameter parsing failed"] - Optional error message if parsing fails */ function parseParamsAs(event: H3Event, schema: ZodSchema, errorCode = 422, errorMessage = "Parameter parsing failed") { const data = event.context.params @@ -56,9 +56,9 @@ function parseParamsAs(event: H3Event, schema: Z * For example `/bar?sort=ASC` binds the query value `sort = "ASC"` * * @param {H3Event} event - Input to parse using the passed `schema` - * @param {ZodSchema} schema - Error code of error if parsing fails - * @param {string} [errorCode=422] - Optional error message if parsing fails - * @param {string} [errorMessage="Data parsing failed"] - Optional error message if parsing fails + * @param {ZodSchema} schema - Zod Schema to parse query with + * @param {string} [errorCode=422] - Error code of error if parsing fails + * @param {string} [errorMessage="Query parsing failed"] - Optional error message if parsing fails */ function parseQueryAs(event: H3Event, schema: ZodSchema, errorCode = 422, errorMessage = "Query parsing failed") { const data = getQuery(event) @@ -68,12 +68,12 @@ function parseQueryAs(event: H3Event, schema: Zo /** * Parse the cookies of a `h3` event. * - * Cookies are part of the HTTP standard and send with every request. + * Cookies are part of the HTTP standard and may be sent with a request. * * @param {H3Event} event - Input to parse using the passed `schema` - * @param {ZodSchema} schema - Error code of error if parsing fails - * @param {string} [errorCode=422] - Optional error message if parsing fails - * @param {string} [errorMessage="Data parsing failed"] - Optional error message if parsing fails + * @param {ZodSchema} schema - Zod Schema to parse Cookie with + * @param {string} [errorCode=422] - Error code of error if parsing fails + * @param {string} [errorMessage="Cookie parsing failed"] - Optional error message if parsing fails */ function parseCookieAs(event: H3Event, schema: ZodSchema, errorCode = 422, errorMessage = "Cookie parsing failed") { const data = parseCookies(event) @@ -83,12 +83,12 @@ function parseCookieAs(event: H3Event, schema: Z /** * Parse the headers of a `h3` event. * - * Cookies are part of the HTTP standard and send with every request. + * Headers are part of the HTTP standard and send with every request. * * @param {H3Event} event - Input to parse using the passed `schema` - * @param {ZodSchema} schema - Error code of error if parsing fails - * @param {string} [errorCode=422] - Optional error message if parsing fails - * @param {string} [errorMessage="Data parsing failed"] - Optional error message if parsing fails + * @param {ZodSchema} schema - Zod Schema to parse headers with + * @param {string} [errorCode=422] - Error code of error if parsing fails + * @param {string} [errorMessage="Header parsing failed"] - Optional error message if parsing fails */ function parseHeaderAs(event: H3Event, schema: ZodSchema, errorCode = 422, errorMessage = "Header parsing failed") { const data = getHeaders(event) @@ -118,8 +118,8 @@ function parseHeaderAs(event: H3Event, schema: Z * ``` * * @param {any | Promise} dataOrPromise - Input to parse using the passed `schema` - * @param {ZodSchema} schema - Error code of error if parsing fails - * @param {string} [errorCode=422] - Optional error message if parsing fails + * @param {ZodSchema} schema - Zod Schema to parse data with + * @param {string} [errorCode=422] - Error code of error if parsing fails * @param {string} [errorMessage="Data parsing failed"] - Optional error message if parsing fails */ async function parseDataAs(dataOrPromise: any | Promise, schema: ZodSchema, errorCode = 422, errorMessage = "Data parsing failed") {