astro-loader-pocketbase 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-loader-pocketbase",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "A content loader for Astro that uses the PocketBase API",
5
5
  "license": "MIT",
6
6
  "author": "Luis Wolf <development@pawcode.de> (https://pawcode.de)",
@@ -15,15 +15,15 @@ export function parseSchema(
15
15
  switch (field.type) {
16
16
  case "number":
17
17
  // Coerce the value to a number
18
- fieldType = z.number({ coerce: true });
18
+ fieldType = z.coerce.number();
19
19
  break;
20
20
  case "bool":
21
21
  // Coerce the value to a boolean
22
- fieldType = z.boolean({ coerce: true });
22
+ fieldType = z.coerce.boolean();
23
23
  break;
24
24
  case "date":
25
25
  // Coerce and parse the value as a date
26
- fieldType = z.date({ coerce: true });
26
+ fieldType = z.coerce.date();
27
27
  break;
28
28
  case "select":
29
29
  if (!field.options.values) {
@@ -58,7 +58,10 @@ export function parseSchema(
58
58
 
59
59
  // If the field is not required, mark it as optional
60
60
  if (!field.required) {
61
- fieldType.isOptional();
61
+ fieldType = z.preprocess(
62
+ (val) => val || undefined,
63
+ z.optional(fieldType)
64
+ );
62
65
  }
63
66
 
64
67
  // Add the field to the fields object