I have a required field in a schema, but when I ad...
# prisma-whats-new
g
I have a required field in a schema, but when I add data, I can leave the field empty. Why is that? Shouldn't it prevent me from adding?
n
@gustavo_pch did you define a default value?
@gustavo_pch what's the value of that field after creation?
g
@nilan The field is required and I didn't even touch the option to add a default value. The schema is like this:
Copy code
type PaymentMethod implements Node {
  createdAt: DateTime!
  icon: String!
  id: ID! @isUnique
  name: String!
  restaurants: [Restaurant!]! @relation(name: "RestaurantPaymentMethod")
  type: PaymentMethodType!
  updatedAt: DateTime!
}
After adding a node without the
icon
field, it just gets set to an empty string apparently.
Maybe that's only a problem when using the console to add data, as probably the empty input for
icon
is interpreted as an empty string instead of an undefined value, right?
t
“” is a valid value for String!
i made the same mistake
n
That's correct @tfiwm
if you want to set something to null with the Data browser, you need click the small button that appears when you try to modify the field
g
@nilan Understood. Thank you!
n
🙂 cheers!