Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
fix(server): override constraints
Browse files Browse the repository at this point in the history
* allows updating posts without tags

Co-authored-by: Kenneth Trecy Tobias <19201.tobias.kennethtrecy.c@gmail.com>
  • Loading branch information
lemredd and KennethTrecy committed Nov 20, 2022
1 parent 9dc6d8e commit 09e1c55
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion routes/api/post(id)/relationships/tag/update.patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { TagIdentifierListDocument } from "$/types/documents/tag"
import type { DeserializedPostDocument } from "$/types/documents/post"
import type { AuthenticatedIDRequest, Response, BaseManagerClass } from "!/types/dependent"

import { MAX_TAGS } from "$/constants/numerical"

import Log from "$!/singletons/log"
import Policy from "!/bases/policy"
import Manager from "%/managers/tag"
Expand Down Expand Up @@ -67,7 +69,17 @@ export default class extends BoundJSONController {
}

makeBodyRuleGenerator(unusedRequest: AuthenticatedIDRequest): FieldRules {
return makeResourceIdentifierListDocumentRules("tag", exists, Manager)
return makeResourceIdentifierListDocumentRules("tag", exists, Manager, {
"postDataRules": {
"constraints": {
"length": {
"maximum": MAX_TAGS,
"minimum": 0
}
},
"pipes": []
}
})
}

get manager(): BaseManagerClass { return PostManager }
Expand Down

0 comments on commit 09e1c55

Please sign in to comment.