mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(schemas): guard string length for default value field (#3868)
should also guard the string length for non-nullable field with a default value as well
This commit is contained in:
parent
08a578b4d1
commit
a265f1f48e
1 changed files with 1 additions and 3 deletions
|
@ -47,9 +47,7 @@ export const generateSchema = ({ name, fields }: TableWithType) => {
|
|||
|
||||
return ` ${camelcase(name)}: z.${isEnum ? `nativeEnum(${type})` : `${type}()`}${
|
||||
// Non-nullable strings should have a min length of 1
|
||||
conditionalString(
|
||||
isString && !(nullable || hasDefaultValue || name === tenantId) && `.min(1)`
|
||||
)
|
||||
conditionalString(isString && !(nullable || name === tenantId) && `.min(1)`)
|
||||
}${
|
||||
// String types value in DB should have a max length
|
||||
conditionalString(isString && maxLength && `.max(${maxLength})`)
|
||||
|
|
Loading…
Reference in a new issue