Custom validation settings on fields?

It would be great if there was a custom validation feature available.

Something like the UID validation, but letting us choose what happens.

image

Some examples:

16 Likes

Hey Max,

This is something we’ve thought long and hard about. We’ve also discussed it at length in this blog post:
https://prismic.io/blog/required-fields

We’re very open to discussing this and especially the other suggested solutions that we talked about in the article including:

  • Completely removing null value (plus replacing them by default values)
  • Pre-fill a new document with all default values.
  • Empty document preview
  • Warning at first publication: Avoid empty fields, mostly for SEO

Please read the article in depth so we can discuss easier the pain points and possible solutions when for implementing of a feature like this :grinning:

Thanks.

Thanks Phil, that is an interesting read. And it also sounds like quite a can of worms! :bug:

I agree that text defaults would be bad for content editors who want to use live preview, so I can understand that isn’t something that would be implemented.

However, default labels (which is my use-case specifically) seems fairly innocuous - though maybe that would lead down a slippery slope of “I can have a default label, why not default text?”

What do you think about maximum and minimum length warnings? Something like the UI being orange around a field, or something. That could be used to indicate fields that probably should be default. (And provide guidance for SEO fields).

I suppose it’s a case of me thinking I have a perfectly reasonable use-case - I’m not going to smack ‘required’ on every single field - but once it is possible, people will, and that will be nasty.

1 Like

Hi Phil,

One of the items that Marcello mentioned which would be quite useful is just having a field length. It wouldn’t have to be a validation and wouldn’t have to prevent publishing but it would be nice if we could set guidelines so content editors can see they have gone over the defined limit by highlighting the field as they edit.

Is this something that could be considered?

6 Likes

Hi Jaie,

Welcome to the community!

I really like that idea, I’ve added it to the request tracker and I’m going to bring it up in person with the features team.

Obviously though this isn’t something that we are working on at the minute. If/when this changes we’ll update you here.

Thanks.

1 Like

Usecase 1
A lot of time the frontend is designed to only accommodate only a certain number of characters. This is where having a min and max limits helps a lot.

Usecase 2
Helps a lot with Metatags. Typically description metatag can only have a limited number of characters being shown in Google serp. Show need to limit the number of characters the creator enters.

3 Likes

Hey Shyamal,

I think these are really strong use cases, especially the second one concerning the descriptions metatag. I've added both of them to the Productboard for the team to see.

If the product team needs more information they'll reach out here.

Thanks.

1 Like

This is being tracked as an open feature request.

If you have another use-case for this feature, you can 'Flag' this topic to reopen. Please use the :heart: button to show your support for the feature and check out our Feature Request Guidelines.

I have another use case for some kind of required fields

I've recently had to create a blog with the following URL structure

/blog/[category]/[post]

If the category is missing, the URL is broken. For the sake of argument, let's say we can't shorten the URL to /blog/post if a category is missing (there are numerous reasons why this solution doesn't work)

In order to ensure a category is defined, you either have to assign posts on a category custom type or assign categories within individual posts. Regardless of your approach, a category is required to make the URL work and for a static build complete

With prismic's current setup, this is impossible. It's very easy to miss adding categories to a post or posts on a category and once it's been missed there's no indication which post/category combination has been missed. You have to go through one by one to find the right one.

In my opinion, prismic should not be opinionated about how URLs should be structured and in this scenario (which is one prismic suggests in one of its examples) it is both opinionated, and that opinion makes creating a solution much more complicated.


Based on the discussion above and my understanding of the approach prismic wants to take I think having a warning within the post if a field is missing required content (like the UID field already does) but also raise that warning up so it's visible on the dashboard (maybe even having a tab dedicated to fixing issues raised in this manner so they can be resolved more easily?)

Even better, having another warning akin to "broken links" on publish to ensure that all posts have all required fields completed would be amazing, while simply returning an uncategorised post to draft if it's trying to be published, like broken links do.

2 Likes

Hey @dan

Thank you for sharing the details of your use case with us. This helps us to have a clear vision of the product's needs from the user's side.

The way links are connected to create URLs later involves having a clear communication process between those who build the Content Modeling of the Custom Types and the Writers and Publishers.

If it is not possible to create an alternative that allows the URLs to be error-proof at the code level, then it is true that a warning would be handy in the writing room UI.

I'm going to add your comment as part of the feature request on the productboard.

This is being tracked as an open feature request.

If you have another use-case for this feature, you can 'Flag' this topic to reopen. Please use the :heart: button to show your support for the feature and check out our Feature Request Guidelines.

I would like to understand if there was any commitment on this feature?

1 Like

Hi @shyamal890,

We're still evaluating required fields and field validation, but it's not on our road map at the moment. Feel free to add a :heart: to this thread to show your support.

Sam

3 Likes

It's shocking this is even being met with resistance. Nearly all meta field apps have this ability for obvious reasons. Limiting number of fields is something we have to do on the frontend on nearly every site.

8 Likes

It's starting to feel like Prismic is trying to find reasons NOT to include fundamental features, instead of coming up with new reasons they should be added.
Nearly every cms supports these, this and deeply nested group/slices have been in limbo for 2 years now and I can't believe they aren't a priority.

5 Likes

Absolutely. This needs to be addressed.

1 Like

I'm really looking forward to implementation of required fields - I worked with other CMS's and nearly all of them have the ability to specify fields that are required.

Some fields on my project MUST be filled in no matter what, I cannot have an article without the title for example. Currently I have to validate on the template and/or provide a placeholder which is a bit meh.

2 Likes

Is there any update on this?
Not seeing this mentioned anywhere by the Prismic team and/or on prismic.io/progress?

Last post about this from Prismic was from 2018?