Wraps your Payload config to validate it against configurable rules at boot, such as kebab-case slugs, GraphQL being disabled, and DTO usage. Provides a base Dto class, transformAndValidate, a withResponse endpoint wrapper and a withDtoReadHook afterRead hook so only exposed fields leave the API. Requires Payload 3 and Next 15 or later.
A TypeScript library providing DTO utilities and validation hooks for Payload CMS
Installation
npm i @byte5digital/payload-assist0
Stars
0
Forks
0
Open Issues
7 months ago
Last Updated
21
Weekly Downloads
v1.2.8
npm Version
40.3 KB
Unpacked Size
2
Dependencies
00 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
| Nov 19, 2026 | 0 |
| Nov 18, 2026 | 0 |
| Nov 17, 2026 | 0 |
| Nov 16, 2026 | 0 |
| Nov 15, 2026 | 0 |
| Nov 14, 2026 | 0 |
| Nov 13, 2026 | 0 |
| Nov 12, 2026 | 0 |
| Nov 11, 2026 | 0 |
| Nov 10, 2026 | 0 |
| Nov 9, 2026 | 0 |
| Nov 8, 2026 | 0 |
| Nov 7, 2026 | 0 |
| Nov 6, 2026 | 0 |
| Nov 5, 2026 | 0 |
| Nov 4, 2026 | 0 |
| Nov 3, 2026 | 0 |
| Nov 2, 2026 | 0 |
| Nov 1, 2026 | 0 |
| Oct 31, 2026 | 0 |
| Oct 30, 2026 | 0 |
| Oct 29, 2026 | 0 |
| Oct 28, 2026 | 0 |
| Oct 27, 2026 | 0 |
| Oct 26, 2026 | 0 |
| Oct 25, 2026 | 0 |
| Oct 24, 2026 | 0 |
| Oct 23, 2026 | 0 |
| Oct 22, 2026 | 0 |
| Oct 21, 2026 | 0 |
| Oct 20, 2026 | 0 |
| Oct 19, 2026 | 0 |
| Oct 18, 2026 | 0 |
| Oct 17, 2026 | 0 |
| Oct 16, 2026 | 0 |
| Oct 15, 2026 | 0 |
| Oct 14, 2026 | 0 |
| Oct 13, 2026 | 0 |
| Oct 12, 2026 | 0 |
| Oct 11, 2026 | 0 |
| Oct 10, 2026 | 0 |
| Oct 9, 2026 | 0 |
| Oct 8, 2026 | 0 |
| Oct 7, 2026 | 0 |
| Oct 6, 2026 | 0 |
| Oct 5, 2026 | 0 |
| Oct 4, 2026 | 0 |
| Oct 3, 2026 | 0 |
| Oct 2, 2026 | 0 |
| Oct 1, 2026 | 0 |
| Sep 30, 2026 | 0 |
| Sep 29, 2026 | 0 |
| Sep 28, 2026 | 0 |
| Sep 27, 2026 | 0 |
| Sep 26, 2026 | 0 |
| Sep 25, 2026 | 0 |
| Sep 24, 2026 | 0 |
| Sep 23, 2026 | 0 |
| Sep 22, 2026 | 0 |
| Sep 21, 2026 | 0 |
| Sep 20, 2026 | 0 |
| Sep 19, 2026 | 0 |
| Sep 18, 2026 | 0 |
| Sep 17, 2026 | 0 |
| Sep 16, 2026 | 0 |
| Sep 15, 2026 | 0 |
| Sep 14, 2026 | 0 |
| Sep 13, 2026 | 0 |
| Sep 12, 2026 | 0 |
| Sep 11, 2026 | 0 |
| Sep 10, 2026 | 0 |
| Sep 9, 2026 | 0 |
| Sep 8, 2026 | 0 |
| Sep 7, 2026 | 0 |
| Sep 6, 2026 | 0 |
14−16 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 14 |
| Dec 4, 2026 | 7 |
| Dec 3, 2026 | 7 |
| Dec 2, 2026 | 7 |
| Dec 1, 2026 | 11 |
| Nov 30, 2026 | 10 |
| Nov 29, 2026 | 11 |
| Nov 28, 2026 | 11 |
| Nov 27, 2026 | 10 |
| Nov 26, 2026 | 9 |
| Nov 25, 2026 | 9 |
| Nov 24, 2026 | 6 |
| Nov 23, 2026 | 6 |
| Nov 22, 2026 | 7 |
| Nov 21, 2026 | 12 |
| Nov 20, 2026 | 27 |
| Nov 19, 2026 | 33 |
| Nov 18, 2026 | 40 |
| Nov 17, 2026 | 36 |
| Nov 16, 2026 | 37 |
| Nov 15, 2026 | 49 |
| Nov 14, 2026 | 44 |
| Nov 13, 2026 | 30 |
| Nov 12, 2026 | 27 |
| Nov 11, 2026 | 36 |
| Nov 10, 2026 | 39 |
| Nov 9, 2026 | 41 |
| Nov 8, 2026 | 29 |
| Nov 7, 2026 | 33 |
| Nov 6, 2026 | 36 |
| Nov 5, 2026 | 34 |
| Nov 4, 2026 | 19 |
| Nov 3, 2026 | 16 |
| Nov 2, 2026 | 16 |
| Nov 1, 2026 | 14 |
| Oct 31, 2026 | 10 |
| Oct 30, 2026 | 6 |
| Oct 29, 2026 | 5 |
| Oct 28, 2026 | 4 |
| Oct 27, 2026 | 4 |
| Oct 26, 2026 | 2 |
| Oct 25, 2026 | 2 |
| Oct 24, 2026 | 3 |
| Oct 23, 2026 | 3 |
| Oct 22, 2026 | 18 |
| Oct 21, 2026 | 26 |
| Oct 20, 2026 | 26 |
| Oct 19, 2026 | 25 |
| Oct 18, 2026 | 30 |
| Oct 17, 2026 | 28 |
| Oct 16, 2026 | 28 |
| Oct 15, 2026 | 14 |
| Oct 14, 2026 | 6 |
| Oct 13, 2026 | 6 |
| Oct 12, 2026 | 6 |
| Oct 11, 2026 | 3 |
| Oct 10, 2026 | 3 |
| Oct 9, 2026 | 3 |
| Oct 8, 2026 | 2 |
| Oct 7, 2026 | 2 |
| Oct 6, 2026 | 6 |
| Oct 5, 2026 | 7 |
| Oct 4, 2026 | 6 |
| Oct 3, 2026 | 12 |
| Oct 2, 2026 | 15 |
| Oct 1, 2026 | 18 |
| Sep 30, 2026 | 18 |
| Sep 29, 2026 | 14 |
| Sep 28, 2026 | 13 |
| Sep 27, 2026 | 16 |
| Sep 26, 2026 | 55 |
| Sep 25, 2026 | 57 |
| Sep 24, 2026 | 55 |
| Sep 23, 2026 | 57 |
| Sep 22, 2026 | 58 |
| Sep 21, 2026 | 61 |
| Sep 20, 2026 | 63 |
| Sep 19, 2026 | 18 |
| Sep 18, 2026 | 15 |
| Sep 17, 2026 | 14 |
| Sep 16, 2026 | 16 |
| Sep 15, 2026 | 15 |
| Sep 14, 2026 | 13 |
| Sep 13, 2026 | 20 |
| Sep 12, 2026 | 32 |
| Sep 11, 2026 | 38 |
| Sep 10, 2026 | 38 |
| Sep 9, 2026 | 38 |
| Sep 8, 2026 | 40 |
| Sep 7, 2026 | 41 |
| Sep 6, 2026 | 30 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1049574899-root)<a href="https://payloaddirectory.dev/plugins/1049574899-root"><img src="https://payloaddirectory.dev/badge/1049574899-root.svg" alt="Payload Directory"></a>README
Utilities to add guardrails, DTO tooling, and ergonomic rules to Payload CMS projects.
yarn add @byte5digital/payload-assist
# or
npm install @byte5digital/payload-assist
Peer deps: Payload v3+, Next v15+. Dependencies class-transformer and reflect-metadata are included in the package.
payloadAssist(payloadConfig, options?): Main function that initializes Assist for Payload, validates your payload config against defined rules, and returns the built config.defaultConfig: Default config with built-in rules and transformAndValidate function (can be spread/overridden).Dto: Base abstract class for response DTOs.transformAndValidate(Dto, data): Validate Payload data and transform to DTO. Uses the configured transformer/validator.withResponse(handler): Enforce DTO-only JSON responses in your custom payload endpoints.withDtoReadHook([{ dto, condition }, { dto }]): Attach to collections to return DTOs from read operations with conditional DTO selection.A comprehensive type for Payload collection access control that includes all available access control methods.
import { AccessControl } from "@byte5digital/payload-assist";
export const MyCollection: CollectionConfig = {
slug: "my-collection",
access: {
admin: ({ req }) => req.user?.role === "admin",
create: ({ req }) => req.user?.role === "admin",
read: ({ req }) => true, // public read
update: ({ req }) => req.user?.role === "admin",
delete: ({ req }) => req.user?.role === "admin",
} satisfies AccessControl,
// ...fields
};
The main payloadAssist function initializes the library, validates your payload config against defined rules, and returns the built config. You can customize the ruleSet and transformAndValidate function through options.
payloadAssist is implemenented as a wrapper function and not as a payload plugin, to ensure it validates the raw config that is set by the user, instead of the config that was previously processed by other plugins and enriched by payload.
false.(config: payloadConfig) => boolean | void; throw to fail with an actionable message and return true if the rule is satisfied.(dto: Dto, data: unknown) => Dto Turn raw Payload data into typed DTOs.Built-in rules:
disableQraphQL: Ensures GraphQL is disabled in your configcollectionsEndpointsUseWithResponse: Ensures all collection endpoints use withResponsecollectionsUseWithDtoReadHook: Ensures all collections use withDtoReadHook in their afterRead hooksimport { buildConfig } from "payload";
import payloadAssist, {
defaultConfig,
PayloadAssistError,
} from "@byte5digital/payload-assist";
export default payloadAssist(
{
// your Payload config
},
{
ruleSet: {
...defaultConfig.ruleSet,
// add/override rules here
secretIsSet: (config) => {
if (config.secret?.length > 0) return true;
throw new PayloadAssistError("A secret needs to be set");
},
},
}
);
Define exactly what leaves your API by modeling responses as DTOs. Only explicitly exposed fields and nested DTOs are serialized.
It is important that all DTOs extend the Dto class. The example below shows the usage with the default transformAndValidate.
import { Dto, Expose, Type } from "@byte5digital/payload-assist";
export class MediaResponse extends Dto {
@Expose() url: string;
@Expose() mimeType: string;
}
export class UserResponse extends Dto {
@Expose() id: number;
@Expose() name: string;
}
export class MyCollectionDto extends Dto {
@Expose() name: string;
@Expose() @Type(() => MediaResponse) image: MediaResponse;
@Expose() @Type(() => UserResponse) owner: UserResponse;
}
Transform any raw Payload doc into a DTO. By default transformAndValidate uses class-transformer, but it can be configured through the payloadAssist options.
import { transformAndValidate } from "@byte5digital/payload-assist";
const payloadDoc = await getPayloadDoc();
const dto = transformAndValidate(MyCollectionDto, payloadDoc);
Use withResponse to guarantee your endpoints return DTOs (and nothing else). It centralizes transform/serialize and standardizes error responses. The transformation strategy is configurable.
import payload from "payload";
import {
withResponse,
transformAndValidate,
} from "@byte5digital/payload-assist";
import { MyDataDto } from "path/to/dtos";
export const MyCollection: CollectionConfig = {
slug: "my-collection",
endpoints: [
{
path: "/my-custom-endpoint",
method: "get",
handler: withResponse(async (req: PayloadRequest) => {
const myData = await req.payload.find({
collection: "my-collection",
// ...additional filter logic
});
const myDataDto = transformAndValidate(MyDataDto, myData);
return {
response: myDataDto,
status: 200,
};
}),
},
],
// ...fields
};
Attach withDtoReadHook to your collections afterReadHooks to transform read results automatically to the given DTOs.
Multiple objects with DTOs can be passed, when they include a condition, only the last item can be without a condition.
The first DTO where the condition is met will be used or the DTO without a condition, if given. If none applies, null will be returned.
So the order of the given DTOs should be: More specific first, default last.
// src/collections/MyCollection.ts
import { CollectionConfig } from "payload/types";
import { withDtoReadHook } from "@byte5digital/payload-assist";
import { MyCollectionDto, MyCollectionAdminDto } from "path/to/dtos";
export const MyCollection: CollectionConfig = {
slug: "my-collection",
hooks: {
afterRead: [
withDtoReadHook(
{
dto: MyCollectionAdminDto,
condition: ({ req: { user } }) => user?.role === "admin",
},
{
dto: MyCollectionDto,
}
),
],
},
// ...fields
};
MIT
We're a development company based in Frankfurt, Germany — remote-friendly, open-minded, and tech-driven. Our team brings deep expertise in Node.js, MedusaJS, Laravel, Umbraco, and decentralized tech like IOTA. We collaborate with clients who care about clean code, scalable solutions, and long-term maintainability.
We contribute to open source, run Laravel DACH Meetups, and support developer communities across the DACH region. Our expertise in e-commerce platforms makes us the perfect partner for building robust, scalable solutions.
If you love building smart solutions with real impact — we should talk.
Connect with us:
Built with 🩵 by byte5
query
Typesafe query filters and field selection for Payload's REST and internal APIs
4526/wk143v1
mcp
Adds Model Context Protocol capabilities to a Payload application
98275.9k/wk46.1kv3 v4
payload operations
Typed custom RPC operations for Payload with shared Zod contracts, server endpoints and type-safe clients
77208/wk3v3
payload oapi
Generate an OpenAPI spec from your Payload config with optional documentation UIs
7631.1k/wk125v3
payload repository
Repository and operations classes that wrap Payload's Local API with typed queries, defaults and transformers
75252/wk0v3
payload plugin openapi
Generate an OpenAPI 3.0, 3.1 or 3.2 spec from your Payload config and serve it with Scalar or Swagger UI
701.4k/wk18v4