zod_rails 0.1.5 → 0.1.6

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -4
  3. data/lib/zod_rails/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8657a14c01a80ca02ca7802858fa13095d3386b49e52a0a5f221f2d6efd8dc20
4
- data.tar.gz: 5e51b264468b0267a00f4c32f64dd2a6bca0f054bea798b3c5b10e987ce63438
3
+ metadata.gz: b3bbdef55113e82c23ae843f93fb14074b05799036856202bc615028373993c1
4
+ data.tar.gz: b638454c118e1f666b971769492f5787bf4e7d20bc736dbac106b77d80689bc2
5
5
  SHA512:
6
- metadata.gz: f817791d90ab6eb88ba1ece45e8b00a815afffd7d55c3958e249dd6319ade7c400a621a47838191f3cd3f52c9c7ab4b4ebdfbb5b9544eab5738f715f9cbf6135
7
- data.tar.gz: e058c4c1931f8947379f60baa0f37c1f0a10a17da4ea8db261ede5cdf2f3b6f3d7b5b4019ec35553e6a3fd60b56af1f9975032b4250aafd62ee7fd3b11c303fe
6
+ metadata.gz: 16e639e56112401f8ffbab59263642fd0c244f5a08be5ed17b8d68eb185e7f6294d849596378eef24123f65ef4b2a79bb2e9dd71e1970154ad616288b334b8b3
7
+ data.tar.gz: 11adc59ed2fbab1da351ab6981ce9de6ff3830c8491e40ebe8ccc31eb5d0f9fd93ef148da41a803d8767f0be6d4f72412c640c755c4793ec4ee161a10b6fcbb5
data/README.md CHANGED
@@ -120,6 +120,8 @@ end
120
120
  | `datetime`, `timestamp` | `z.iso.datetime()` |
121
121
  | `json`, `jsonb` | `z.json()` |
122
122
  | `uuid` | `z.uuid()` |
123
+ | `time` | `z.string()` |
124
+ | `binary` | `z.string()` |
123
125
  | `enum` | `z.enum([...])` |
124
126
 
125
127
  ## Validation Mappings
@@ -128,7 +130,7 @@ ZodRails introspects your model validations and maps them to Zod constraints:
128
130
 
129
131
  | Rails Validation | Zod Constraint |
130
132
  |------------------|----------------|
131
- | `presence: true` | `.min(1)` for strings |
133
+ | `presence: true` | `.min(1)` for string/text columns |
132
134
  | `length: { minimum: n }` | `.min(n)` |
133
135
  | `length: { maximum: n }` | `.max(n)` |
134
136
  | `length: { is: n }` | `.length(n)` |
@@ -160,7 +162,7 @@ import { z } from "zod";
160
162
 
161
163
  export const UserSchema = z.object({
162
164
  id: z.int(),
163
- email: z.string().min(1).regex(/\A[^@\s]+@[^@\s]+\z/),
165
+ email: z.string().min(1).regex(/^[^@\s]+@[^@\s]+$/),
164
166
  name: z.string().min(2).max(100),
165
167
  age: z.int().gt(0).lt(150).nullable(),
166
168
  role: z.enum(["member", "admin", "moderator"]),
@@ -171,7 +173,7 @@ export const UserSchema = z.object({
171
173
  export type User = z.infer<typeof UserSchema>;
172
174
 
173
175
  export const UserInputSchema = z.object({
174
- email: z.string().min(1).regex(/\A[^@\s]+@[^@\s]+\z/),
176
+ email: z.string().min(1).regex(/^[^@\s]+@[^@\s]+$/),
175
177
  name: z.string().min(2).max(100),
176
178
  age: z.int().gt(0).lt(150).nullish(),
177
179
  role: z.enum(["member", "admin", "moderator"]).optional()
@@ -193,7 +195,7 @@ ZodRails generates two schema variants:
193
195
  - Represents data for form submission
194
196
  - Excludes configured columns (defaults: `id`, `created_at`, `updated_at`)
195
197
  - Uses `.optional()` for columns with database defaults
196
- - Uses `.nullish()` for nullable columns without defaults
198
+ - Uses `.nullish()` for nullable columns (accepts both `null` and `undefined`)
197
199
 
198
200
  ## Integrating with Forms
199
201
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZodRails
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zod_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Kelly