Is there a built in method of preventing empty strings for required fields. For instance, if I require a user provide a name, "" (empty string) should not be a valid submission. How can I make NULL and "" return the same error? I've got a lot of forms that have this use case, so writing a bunch of custom error handlers would be a real pain. Seems like there should be a way to do this automatically.
r
Ryan
05/25/2020, 10:16 AM
Hey @jt 👋
The only way possible would be to write a custom resolver and have a check on
NULL
and
''
.
This is because Prisma follows the DB constraints on
not null
so only nulls will be check for. An empty string is valid in that case.