Diego
Diego
PPrisma
Created by Diego on 5/3/2024 in #help-and-questions
Prisma not recognizing Date-only values
I have a DateTime field with @db.Date annotation, but it still expects me to pass a full ISO 8601 date+time string. The model:
model Usuario {
id Int @id @default(autoincrement())

nome String @db.VarChar(80)
email String @db.VarChar(100)
telefone String? @db.VarChar(20)
dataNascimento DateTime? @db.Date
}
model Usuario {
id Int @id @default(autoincrement())

nome String @db.VarChar(80)
email String @db.VarChar(100)
telefone String? @db.VarChar(20)
dataNascimento DateTime? @db.Date
}
The error:
PrismaClientValidationError:

Invalid `prisma.usuario.create()` invocation:

{

data: {

email: "?????",

senha: "$2b$10$NA1r0R9HHOBql7TIyPP6me6cp2xln.zsdwN4ITAKhlBXJ2nX2ZMp.",

nome: "DIEGO",

dataNascimento: "1995-01-01",

~~~~~~~~~~~~

codigoAtivacao: "YWNlOTdlMjQtMDM4My00MTBhLWI1MjgtN2NlZTA2ODNlNWVi"

}

}

Invalid value for argument `dataNascimento`: premature end of input. Expected ISO-8601 DateTime.
PrismaClientValidationError:

Invalid `prisma.usuario.create()` invocation:

{

data: {

email: "?????",

senha: "$2b$10$NA1r0R9HHOBql7TIyPP6me6cp2xln.zsdwN4ITAKhlBXJ2nX2ZMp.",

nome: "DIEGO",

dataNascimento: "1995-01-01",

~~~~~~~~~~~~

codigoAtivacao: "YWNlOTdlMjQtMDM4My00MTBhLWI1MjgtN2NlZTA2ODNlNWVi"

}

}

Invalid value for argument `dataNascimento`: premature end of input. Expected ISO-8601 DateTime.
What should I do? Am I doing something wrong? (I just migrated from Sequelize, so I'm quite new to Prisma)
3 replies