Closed DomDew closed 5 days ago
The latest updates on your projects. Learn more about Vercel for Git βοΈ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
documentation | β Ready (Inspect) | Visit Preview | π¬ Add feedback | Oct 29, 2024 3:50pm |
Thank you so much for your contribution and effort, @DomDew!
I'll add a developer from the Strapi core team as a reviewer (cc @innerdvations). At the moment I'm not 100% sure whether we want to expose these methods in the public documentation or not. Apart from that, from a pure technical writing point of view, your PR looks great! π
Hey hey @pwizla,
just to follow up:
The approach with accessing the validate
and sanitize
functions through the strapi.contentApi
function is listed as the official migration approach in the breaking changes guide for v4
to v5
.
Meaning the PR would update the docs to what is described in the migration guide - I overlooked that prior.
What does it do?
Lists the sanitization and validation methods from the
contentApi
as methods of the global strapi namespace.Why is it needed?
With the update to v5 the
validate
andsanitize
methods exported from the@strapi/utils
package no longer expose the validation and sanitization methods through thecontentApi
. Instead, they would now have to be accessed through thecreateAPISanitizers
orcreateAPIValidators
methods, which would need to take agetModel
callback as a mandatory argument. This would make custom validation code a tiny bit more cluttered.In keeping consistent with the existing pattern as described by the current documentation, they could however still be accessed from the
contentApi
key from globalstrapi
namespace.Either way, the documentation needs to be corrected in either describing custom validation using the
createAPISanitizers
or by accessing thecontentApi
from the global namespace.Let me know what is more in line with you design philosophy and I'll gladly update the docs βοΈ.
Thanks for the great project π€
Related issue(s)/PR(s)
Let us know if this is related to any issue/pull request