Password field required but empty string is considered valid

framework

#1

My user type must have a name and password:

type User @model {
	id: ID! @isUnique
	email: String! @isUnique
	password: String!
    name: String!
}

However if I pass an empty string the user is still created:

mutation {
  createUser (email: "james@gmail.com", password: "", name: ""){
    id
    name
    email
  }
}

Is this a bug? I couldn’t see a way in the docs to set a minimum length on string, but doesn’t this make the required parameter almost pointless?


#2

It’s because String! means that null is not allowed.
An empty string is still a value.

A directive to be able to specify min length for instance, is under consideration.
https://github.com/graphcool/prisma/issues/728


#3

Thanks, hope this feature makes it in.