Provides helper functions that plug into the validate option of Payload collection fields. A generic validator takes one or more conditions with custom error messages, and ready-made validators cover regex, email, URL and IP address checks on text fields. It can also wrap valibot schemas for more concise conditions. Targets Payload 3.
Easy validation handlers for Payload CMS collection's fields
Installation
npm i payload-field-validators4
Stars
0
Forks
0
Open Issues
1 years ago
Last Updated
25
Weekly Downloads
v0.2.3
npm Version
20.1 KB
Unpacked Size
1
Dependencies
40 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 4 |
| Dec 4, 2026 | 4 |
| Dec 3, 2026 | 4 |
| Dec 2, 2026 | 4 |
| Dec 1, 2026 | 4 |
| Nov 30, 2026 | 4 |
| Nov 29, 2026 | 4 |
| Nov 28, 2026 | 4 |
| Nov 27, 2026 | 4 |
| Nov 26, 2026 | 4 |
| Nov 25, 2026 | 4 |
| Nov 24, 2026 | 4 |
| Nov 23, 2026 | 4 |
| Nov 22, 2026 | 4 |
| Nov 21, 2026 | 4 |
| Nov 20, 2026 | 4 |
| Nov 19, 2026 | 4 |
| Nov 18, 2026 | 4 |
| Nov 17, 2026 | 4 |
| Nov 16, 2026 | 4 |
| Nov 15, 2026 | 4 |
| Nov 14, 2026 | 4 |
| Nov 13, 2026 | 4 |
| Nov 12, 2026 | 4 |
| Nov 11, 2026 | 4 |
| Nov 10, 2026 | 4 |
| Nov 9, 2026 | 4 |
| Nov 8, 2026 | 4 |
| Nov 7, 2026 | 4 |
| Nov 6, 2026 | 4 |
| Nov 5, 2026 | 4 |
| Nov 4, 2026 | 4 |
| Nov 3, 2026 | 4 |
| Nov 2, 2026 | 4 |
| Nov 1, 2026 | 4 |
| Oct 31, 2026 | 4 |
| Oct 30, 2026 | 4 |
| Oct 29, 2026 | 4 |
| Oct 28, 2026 | 4 |
| Oct 27, 2026 | 4 |
| Oct 26, 2026 | 4 |
| Oct 25, 2026 | 4 |
| Oct 24, 2026 | 4 |
| Oct 23, 2026 | 4 |
| Oct 22, 2026 | 4 |
| Oct 21, 2026 | 4 |
| Oct 20, 2026 | 4 |
| Oct 19, 2026 | 4 |
| Oct 18, 2026 | 4 |
| Oct 17, 2026 | 4 |
| Oct 16, 2026 | 4 |
| Oct 15, 2026 | 4 |
| Oct 14, 2026 | 4 |
| Oct 13, 2026 | 4 |
| Oct 12, 2026 | 4 |
| Oct 11, 2026 | 4 |
| Oct 10, 2026 | 4 |
| Oct 9, 2026 | 4 |
| Oct 8, 2026 | 4 |
| Oct 7, 2026 | 4 |
| Oct 6, 2026 | 4 |
| Oct 5, 2026 | 4 |
| Oct 4, 2026 | 4 |
| Oct 3, 2026 | 4 |
| Oct 2, 2026 | 4 |
| Oct 1, 2026 | 4 |
| Sep 30, 2026 | 4 |
| Sep 29, 2026 | 4 |
| Sep 28, 2026 | 4 |
| Sep 27, 2026 | 4 |
| Sep 26, 2026 | 4 |
| Sep 25, 2026 | 4 |
| Sep 24, 2026 | 4 |
| Sep 23, 2026 | 4 |
| Sep 22, 2026 | 4 |
| Sep 21, 2026 | 4 |
| Sep 20, 2026 | 4 |
| Sep 19, 2026 | 4 |
| Sep 18, 2026 | 4 |
| Sep 17, 2026 | 4 |
| Sep 16, 2026 | 4 |
| Sep 15, 2026 | 4 |
| Sep 14, 2026 | 4 |
| Sep 13, 2026 | 4 |
| Sep 12, 2026 | 4 |
| Sep 11, 2026 | 4 |
| Sep 10, 2026 | 4 |
| Sep 9, 2026 | 4 |
| Sep 8, 2026 | 4 |
| Sep 7, 2026 | 4 |
| Sep 6, 2026 | 4 |
20+9 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 20 |
| Dec 4, 2026 | 7 |
| Dec 3, 2026 | 8 |
| Dec 2, 2026 | 8 |
| Dec 1, 2026 | 9 |
| Nov 30, 2026 | 5 |
| Nov 29, 2026 | 11 |
| Nov 28, 2026 | 11 |
| Nov 27, 2026 | 11 |
| Nov 26, 2026 | 9 |
| Nov 25, 2026 | 9 |
| Nov 24, 2026 | 9 |
| Nov 23, 2026 | 9 |
| Nov 22, 2026 | 4 |
| Nov 21, 2026 | 5 |
| Nov 20, 2026 | 4 |
| Nov 19, 2026 | 6 |
| Nov 18, 2026 | 11 |
| Nov 17, 2026 | 11 |
| Nov 16, 2026 | 13 |
| Nov 15, 2026 | 14 |
| Nov 14, 2026 | 14 |
| Nov 13, 2026 | 19 |
| Nov 12, 2026 | 27 |
| Nov 11, 2026 | 26 |
| Nov 10, 2026 | 25 |
| Nov 9, 2026 | 23 |
| Nov 8, 2026 | 21 |
| Nov 7, 2026 | 20 |
| Nov 6, 2026 | 15 |
| Nov 5, 2026 | 6 |
| Nov 4, 2026 | 2 |
| Nov 3, 2026 | 2 |
| Nov 2, 2026 | 5 |
| Nov 1, 2026 | 4 |
| Oct 31, 2026 | 6 |
| Oct 30, 2026 | 6 |
| Oct 29, 2026 | 5 |
| Oct 28, 2026 | 5 |
| Oct 27, 2026 | 5 |
| Oct 26, 2026 | 3 |
| Oct 25, 2026 | 9 |
| Oct 24, 2026 | 8 |
| Oct 23, 2026 | 8 |
| Oct 22, 2026 | 8 |
| Oct 21, 2026 | 9 |
| Oct 20, 2026 | 9 |
| Oct 19, 2026 | 8 |
| Oct 18, 2026 | 2 |
| Oct 17, 2026 | 2 |
| Oct 16, 2026 | 2 |
| Oct 15, 2026 | 3 |
| Oct 14, 2026 | 2 |
| Oct 13, 2026 | 2 |
| Oct 12, 2026 | 2 |
| Oct 11, 2026 | 3 |
| Oct 10, 2026 | 2 |
| Oct 9, 2026 | 2 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 2 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 3 |
| Oct 2, 2026 | 7 |
| Oct 1, 2026 | 7 |
| Sep 30, 2026 | 7 |
| Sep 29, 2026 | 12 |
| Sep 28, 2026 | 11 |
| Sep 27, 2026 | 12 |
| Sep 26, 2026 | 13 |
| Sep 25, 2026 | 11 |
| Sep 24, 2026 | 11 |
| Sep 23, 2026 | 13 |
| Sep 22, 2026 | 13 |
| Sep 21, 2026 | 13 |
| Sep 20, 2026 | 13 |
| Sep 19, 2026 | 10 |
| Sep 18, 2026 | 8 |
| Sep 17, 2026 | 10 |
| Sep 16, 2026 | 10 |
| Sep 15, 2026 | 5 |
| Sep 14, 2026 | 7 |
| Sep 13, 2026 | 7 |
| Sep 12, 2026 | 7 |
| Sep 11, 2026 | 12 |
| Sep 10, 2026 | 10 |
| Sep 9, 2026 | 9 |
| Sep 8, 2026 | 12 |
| Sep 7, 2026 | 12 |
| Sep 6, 2026 | 11 |
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/956096125-root)<a href="https://payloaddirectory.dev/plugins/956096125-root"><img src="https://payloaddirectory.dev/badge/956096125-root.svg" alt="Payload Directory"></a>README
Easy validation handlers for Payload CMS collection's fields
Assuming we have a Collection
export default MyCollection: CollectionConfig = {
// other fields..
{
name: "number_field",
type: "number",
},
{
name: "text_field",
type: "text",
}
// other fields..
}
We can add a validator to TextField:
{
// other configs..
validate: (value: any) =>
validateField({
condition: value.length < 100,
})
}
Similarly, we can add a validator to NumberField:
{
// other configs..
validate: (value: any) =>
validateField({
condition: value > 100,
})
}
The default message will be "Invalid input"
message param:{
// other field's configs..
name: "percentage_usage",
validate: (value: any) => validateField({
condition: value > 20 and value < 50,
message: "percentage must be between 20 to 50 %"
})
}
NumberField and for each case to show appropriate message:{
name: "grade",
type: "number",
required: true,
validate: (value: any) => validateField([
{
condition: value >= 55,
message: "Grade must be at minimum 55"
},
{
condition: typeof value === "number" && Number.isInteger(value),
message: "Grade must be an Integer"
}
])
},
You can use form validation libraries like valibot/zod/vest to write more concise conditions
using valibotCheck utility
// import valibot
import * as v from "valibot";
//....
{
name: "grade",
type: "number",
required: true,
validate: (value: any) => validateField({
condition: valibotCheck(v.pipe(v.number(), v.integer(), v.minValue(55), value)),
message: "Grade must be an Integer, minimum 55"
})
},
TextFieldconst onlyLettersRegex = /^[a-zA-Z0-9]+$/;
export default MyCollection: CollectionConfig = {
{
name: "name",
type: "text",
admin: {
readOnly: false,
hidden: false
},
validate: (value: any) => validateRegex(
onlyLettersRegex,
value,
"Name must not contain special characters" // (optional error message)
),
required: true
}
TextFieldexport default MyCollection: CollectionConfig = {
{
name: "email",
type: "text",
validate: (value: any) => validateEmail(value, optionaLmessage), // --> add this line
required: true
}
TextFieldexport default MyCollection: CollectionConfig = {
{
name: "url",
type: "text",
admin: {
readOnly: false,
hidden: false
},
validate: (value: any) => validateUrl(valuem optionaLmessage), // --> add this line
required: true
}
TextFieldexport default MyCollection: CollectionConfig = {
{
name: "website_url",
type: "text",
admin: {
readOnly: false,
hidden: false
},
validate: (value: any) => validateIPAddress(value), // --> add this line
required: true
}
Topics
payload plugin json form builder
Edit a Payload json field as real admin fields, with the form shape built in the admin panel
72441/wk37v3
encrypted fields
Encrypt individual field values in the database with an encryptedField helper for collections
6585/wk84v3
link field
Link field and Lexical link feature supporting internal document and custom URL links
6346/wk0v4
icons
Manage SVG icons as CMS content with icon sets, an admin select widget and a server Icon component
5732/wk37v3
payload plugin icons
Icon picker field for Payload with Lucide and Phosphor providers and a React rendering component
5522/wk2v3
form builder
Let admin editors build and manage forms from within the Payload admin panel
100171.2k/wk46.1kv3 v4