0
Fork 0
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:
simeng-li 2023-05-15 17:10:40 +08:00 committed by GitHub
parent 176e70190f
commit 30cd7727de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View file

@ -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);

View file

@ -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(