mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(schemas): remove the notnull string min-length guard from response type (#3844)
remove the notnull string min-length guard from response type
This commit is contained in:
parent
176e70190f
commit
30cd7727de
2 changed files with 5 additions and 6 deletions
|
@ -64,6 +64,11 @@ describe('admin console application', () => {
|
|||
expect(updatedAgainApplication.isAdmin).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should get demo app application successfully', async () => {
|
||||
const application = await getApplication('demo-app');
|
||||
expect(application.id).toBe('demo-app');
|
||||
});
|
||||
|
||||
it('should fetch all applications created above', async () => {
|
||||
const applications = await getApplications();
|
||||
const applicationNames = applications.map(({ name }) => name);
|
||||
|
|
|
@ -65,7 +65,6 @@ export const generateSchema = ({ name, fields }: TableWithType) => {
|
|||
`const guard: Guard<${modelName}> = z.object({`,
|
||||
|
||||
...fields.map(
|
||||
// eslint-disable-next-line complexity
|
||||
({ name, type, isArray, isEnum, nullable, tsType, isString, maxLength, hasDefaultValue }) => {
|
||||
if (tsType) {
|
||||
return ` ${camelcase(name)}: ${camelcase(tsType)}Guard${conditionalString(
|
||||
|
@ -74,11 +73,6 @@ 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)`
|
||||
)
|
||||
}${
|
||||
// String types value in DB should have a max length
|
||||
conditionalString(isString && maxLength && `.max(${maxLength})`)
|
||||
}${conditionalString(isArray && '.array()')}${conditionalString(
|
||||
|
|
Loading…
Reference in a new issue