nickmazuk
nickmazuk
Explore posts from servers
Aarktype
Created by nickmazuk on 4/19/2025 in #questions
`.configure` not being applied
Hey all! I'm trying to use .configure to customize the error messages and it seems like it isn't being applied. For instance if you put this in the playground, you'll see that the error message is "Password must contain at least one character that isn't a letter or number". My expectation is that it would either be 'override problem' or 'override message' because that's what I've configured. Additionally, if I add console.log statements to the problem and message functions it looks like those never run. What am I doing wrong?
import { type } from "arktype"

const Thing = type('string >= 12')
.narrow((str, ctx) => {
if (!/[A-Z]/.test(str)) {
ctx.error('Password must contain at least one uppercase letter')
}
if (!/[a-z]/.test(str)) {
ctx.error('Password must contain at least one lowercase letter')
}
if (!/\d/.test(str)) {
ctx.error('Password must contain at least one number')
}
if (!/[^\w\s]/.test(str)) {
ctx.error("Password must contain at least one character that isn't a letter or number")
}
return true
})
.configure({
problem: () => {
return 'override problem'
},
message: () => {
return 'override message'
},
})

const out = Thing("Password1234")
import { type } from "arktype"

const Thing = type('string >= 12')
.narrow((str, ctx) => {
if (!/[A-Z]/.test(str)) {
ctx.error('Password must contain at least one uppercase letter')
}
if (!/[a-z]/.test(str)) {
ctx.error('Password must contain at least one lowercase letter')
}
if (!/\d/.test(str)) {
ctx.error('Password must contain at least one number')
}
if (!/[^\w\s]/.test(str)) {
ctx.error("Password must contain at least one character that isn't a letter or number")
}
return true
})
.configure({
problem: () => {
return 'override problem'
},
message: () => {
return 'override message'
},
})

const out = Thing("Password1234")
8 replies
DTDrizzle Team
Created by nickmazuk on 8/19/2023 in #help
Not equal with relational queries
Has anyone used ne with relational queries? When I use the callback syntax, I get the following type error:
where: (table, { ne }) => ne(table.name, "name")
^^ Property 'ne' does not exist on type { ... }
where: (table, { ne }) => ne(table.name, "name")
^^ Property 'ne' does not exist on type { ... }
4 replies
DTDrizzle Team
Created by nickmazuk on 8/13/2023 in #help
Invalid serialization of JSON blobs
Has anyone gotten default values of JSON blobs to work with SQLite? When I try using an empty array, the SQL migration does not have a default value (despite having the DEFAULT keyword).
array: blob("array", { mode: 'json' }).$type<string[]>().default([]).notNull()
array: blob("array", { mode: 'json' }).$type<string[]>().default([]).notNull()
`array` blob DEFAULT NOT NULL,
`array` blob DEFAULT NOT NULL,
If I use an object, the default value is the toString serialization: [object Object], not the JSON.stringify serialization.
object: blob("object", { mode: 'json' }).$type<{}>().default({}).notNull()
object: blob("object", { mode: 'json' }).$type<{}>().default({}).notNull()
`object` blob DEFAULT [object Object] NOT NULL,
`object` blob DEFAULT [object Object] NOT NULL,
I also posted an issue on GitHub since this seems like a bug, but asking here in case any of you have found a workaround. https://github.com/drizzle-team/drizzle-orm/issues/1036
1 replies
DTDrizzle Team
Created by nickmazuk on 8/12/2023 in #help
SQLite: timestamp vs timestamp_ms modes
The SQLite column types docs mention there's multiple modes for integers. What's the difference between timestamp_ms and timestamp modes?
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";

// you can customize integer mode to be timestamp, timestamp_ms
integer('id', { mode: 'timestamp_ms' })
integer('id', { mode: 'timestamp' }) // Date
import { integer, sqliteTable } from "drizzle-orm/sqlite-core";

// you can customize integer mode to be timestamp, timestamp_ms
integer('id', { mode: 'timestamp_ms' })
integer('id', { mode: 'timestamp' }) // Date
My assumption is the following: - timestamp_ms: Stores the timestamp including the milliseconds. Same precision as Date.now(). Equivalent to TIMESTAMP in MySQL. - timestamp: Stores the date only. Same precision as 2023-08-09. Equivalent to DATE in MySQL. https://github.com/drizzle-team/drizzle-orm/discussions/1007
7 replies