Home

>

Tools

>

Payload CMS

>

Releases

>

Release 0.16.1

Payload CMS Release: Release 0.16.1

Tag Name: v0.16.1

Release Date: 4/29/2022

Payload CMS LogoPayload CMS

Payload CMS is a modern, self-hosted headless content management system built with TypeScript, Node.js, and MongoDB. It's designed specifically for developers who want full control over their content management system while maintaining a powerful admin interface for content editors.

TL;DR

Payload CMS v0.16.1 is a minor release that exposes the payload instance within server-side validation arguments, allowing for more powerful validation logic. This update enables developers to access the full payload API during field validation, opening up possibilities for complex validation scenarios that require database queries or other payload operations.

Highlight of the Release

    • Payload instance now available in server-side validation arguments
    • Enhanced validation capabilities through access to the full payload API
    • Documentation links updated

Migration Guide

No migration is required for this release. The new feature is additive and doesn't break existing functionality.

If you're already using server-side validation functions, you can now optionally access the payload instance through the validation arguments without any changes to your existing code.

Upgrade Recommendations

This is a minor feature release that adds functionality without breaking changes. It's safe to upgrade from v0.16.0 to v0.16.1 without code modifications.

To upgrade:

npm install [email protected]
# or
yarn add [email protected]

Bug Fixes

No specific bug fixes were mentioned in this release.

New Features

Payload Instance in Validation Arguments

The payload instance is now exposed within server-side validation arguments, providing access to the full payload API during field validation. This enhancement allows developers to:

  • Query collections and globals during validation
  • Access utility methods provided by the payload instance
  • Implement more complex validation rules that depend on other data

Example usage:

{
  fields: [
    {
      name: 'title',
      type: 'text',
      validate: async (value, { payload }) => {
        // Now you can use payload to query other collections
        const existingDocs = await payload.find({
          collection: 'posts',
          where: {
            title: {
              equals: value
            }
          }
        });
        
        if (existingDocs.totalDocs > 0) {
          return 'A post with this title already exists';
        }
        
        return true;
      }
    }
  ]
}

Security Updates

No security fixes were mentioned in this release.

Performance Improvements

No specific performance improvements were mentioned in this release.

Impact Summary

This release enhances the developer experience by providing access to the payload instance within server-side validation functions. This is particularly valuable for implementing complex validation rules that need to query the database or use other payload functionality.

The change is non-breaking and purely additive, meaning existing validation functions will continue to work as before. Developers can now optionally leverage the payload instance in their validation logic when needed.

Internal testing for localization default values was also included in this release, though no user-facing changes related to this were mentioned.

Full Release Notes

0.16.1 (2022-04-29)

Features

  • exposes payload within server-side validation args (e46b942)

Statistics:

File Changed31
Line Additions510
Line Deletions241
Line Changes751
Total Commits7

User Affected:

  • Can now access the payload instance within server-side validation functions
  • Can perform database queries or other payload operations during field validation
  • Can implement more complex validation logic that depends on other collections or data

Contributors:

DanRibbensjmikrut