summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/pink-yaks-exercise.md5
-rw-r--r--packages/astro/src/types/public/config.ts42
2 files changed, 46 insertions, 1 deletions
diff --git a/.changeset/pink-yaks-exercise.md b/.changeset/pink-yaks-exercise.md
new file mode 100644
index 000000000..158f3612e
--- /dev/null
+++ b/.changeset/pink-yaks-exercise.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Updates the `env` configuration reference docs to include a full API reference for `envField`.
diff --git a/packages/astro/src/types/public/config.ts b/packages/astro/src/types/public/config.ts
index aa1eabd82..76b224824 100644
--- a/packages/astro/src/types/public/config.ts
+++ b/packages/astro/src/types/public/config.ts
@@ -1438,7 +1438,7 @@ export interface AstroUserConfig {
* @version 5.0.0
* @description
*
- * An object that uses `envField` to define the data type (`string`, `number`, or `boolean`) and properties of your environment variables: `context` (client or server), `access` (public or secret), a `default` value to use, and whether or not this environment variable is `optional` (defaults to `false`).
+ * An object that uses `envField` to define the data type and properties of your environment variables: `context` (client or server), `access` (public or secret), a `default` value to use, and whether or not this environment variable is `optional` (defaults to `false`).
* ```js
* // astro.config.mjs
* import { defineConfig, envField } from "astro/config"
@@ -1453,6 +1453,46 @@ export interface AstroUserConfig {
* }
* })
* ```
+ *
+ * `envField` supports four data types: string, number, enum, and boolean. `context` and `access` are required properties for all data types. The following shows the complete list of properties available for each data type:
+ *
+ * ```js
+ * import { envField } from "astro/config"
+ *
+ * envField.string({
+ * // context & access
+ * optional: true,
+ * default: "foo",
+ * max: 20,
+ * min: 1,
+ * length: 13,
+ * url: true,
+ * includes: "oo",
+ * startsWith: "f",
+ * endsWith: "o",
+ * })
+ * envField.number({
+ * // context & access
+ * optional: true,
+ * default: 15,
+ * gt: 2,
+ * min: 1,
+ * lt: 3,
+ * max: 4,
+ * int: true,
+ * })
+ * envField.boolean({
+ * // context & access
+ * optional: true,
+ * default: true,
+ * })
+ * envField.enum({
+ * // context & access
+ * values: ['foo', 'bar', 'baz'], // required
+ * optional: true,
+ * default: 'baz',
+ * })
+ * ```
*/
schema?: EnvSchema;