Closed TatisLois closed 1 year ago
I think we could add the beforeValidate to this file -> https://github.com/joas8211/payload-tenancy/blob/f687c556ab5518be52a3e732590136237943ed4d/src/fields/tenantSlug.ts
I don't know if I consider this a bug. URL can contain almost, if not, any character but it just has to be encoded in the correct way. There actually is a bug in path mapping middleware though. It should decode the slug before trying to find tenant that matches that slug. Also I'm thinking that maybe we make it more easier to modify the fields, so that users of this plugin that want to limit the way slug can be formatted, can do that by adding their own validation or auto formatting.
@TatisLois, how does that sound to you? Would it be enough if I add the slug decoding and allow to modify the fields?
@joas8211 that would be perfect, currently I was trying to modify it in a beforeOperation
or beforeRead
hook on the collection but if you extended the config then that would make it much more powerful!
Following issues are split from this issue: #11, #8. Closing this issue in favor or those split issues.
I noticed that a slug can be saved in a invalid format for example
my slug
, ideally this would convert tomy-slug
for the user.In other payload projects i've used this utils in a
beforeValidate
hook, what are your thoughts of including it into the project or a similar solution?Alternatively is it possible to extend your tenancy collection to pass this in myself for the field?