chore: fixed edgecases for data being null
This commit is contained in:
@@ -503,6 +503,7 @@ export class TeamCollectionService {
|
|||||||
if (O.isNone(isOwner)) return E.left(TEAM_NOT_OWNER);
|
if (O.isNone(isOwner)) return E.left(TEAM_NOT_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data === '') return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
if (data) {
|
if (data) {
|
||||||
const jsonReq = stringToJson(data);
|
const jsonReq = stringToJson(data);
|
||||||
if (E.isLeft(jsonReq)) return E.left(TEAM_COLL_DATA_INVALID);
|
if (E.isLeft(jsonReq)) return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
@@ -1015,7 +1016,7 @@ export class TeamCollectionService {
|
|||||||
*/
|
*/
|
||||||
async updateTeamCollection(
|
async updateTeamCollection(
|
||||||
collectionID: string,
|
collectionID: string,
|
||||||
collectionData: string,
|
collectionData: string = null,
|
||||||
newTitle: string = null,
|
newTitle: string = null,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
@@ -1024,6 +1025,7 @@ export class TeamCollectionService {
|
|||||||
if (!isTitleValid) return E.left(TEAM_COLL_SHORT_TITLE);
|
if (!isTitleValid) return E.left(TEAM_COLL_SHORT_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (collectionData === '') return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
if (collectionData) {
|
if (collectionData) {
|
||||||
const jsonReq = stringToJson(collectionData);
|
const jsonReq = stringToJson(collectionData);
|
||||||
if (E.isLeft(jsonReq)) return E.left(TEAM_COLL_DATA_INVALID);
|
if (E.isLeft(jsonReq)) return E.left(TEAM_COLL_DATA_INVALID);
|
||||||
@@ -1033,7 +1035,7 @@ export class TeamCollectionService {
|
|||||||
const updatedTeamCollection = await this.prisma.teamCollection.update({
|
const updatedTeamCollection = await this.prisma.teamCollection.update({
|
||||||
where: { id: collectionID },
|
where: { id: collectionID },
|
||||||
data: {
|
data: {
|
||||||
data: collectionData,
|
data: collectionData ?? undefined,
|
||||||
title: newTitle ?? undefined,
|
title: newTitle ?? undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ export class UserCollectionService {
|
|||||||
const isTitleValid = isValidLength(title, this.TITLE_LENGTH);
|
const isTitleValid = isValidLength(title, this.TITLE_LENGTH);
|
||||||
if (!isTitleValid) return E.left(USER_COLL_SHORT_TITLE);
|
if (!isTitleValid) return E.left(USER_COLL_SHORT_TITLE);
|
||||||
|
|
||||||
|
if (data === '') return E.left(USER_COLL_DATA_INVALID);
|
||||||
if (data) {
|
if (data) {
|
||||||
const jsonReq = stringToJson(data);
|
const jsonReq = stringToJson(data);
|
||||||
if (E.isLeft(jsonReq)) return E.left(USER_COLL_DATA_INVALID);
|
if (E.isLeft(jsonReq)) return E.left(USER_COLL_DATA_INVALID);
|
||||||
@@ -1099,6 +1100,8 @@ export class UserCollectionService {
|
|||||||
userCollectionID: string,
|
userCollectionID: string,
|
||||||
userID: string,
|
userID: string,
|
||||||
) {
|
) {
|
||||||
|
if (collectionData === '') return E.left(USER_COLL_DATA_INVALID);
|
||||||
|
|
||||||
if (collectionData) {
|
if (collectionData) {
|
||||||
const jsonReq = stringToJson(collectionData);
|
const jsonReq = stringToJson(collectionData);
|
||||||
if (E.isLeft(jsonReq)) return E.left(USER_COLL_DATA_INVALID);
|
if (E.isLeft(jsonReq)) return E.left(USER_COLL_DATA_INVALID);
|
||||||
|
|||||||
Reference in New Issue
Block a user