Fluid.Core 2.3.0, add Content Field handlers to enforce validation in the content API - This week in Orchard (23/12/2022)

Gábor Domonkos's avatar
Announcement, This week in Orchard, Content field, Liquid

Fluid.Core 2.3.0, add Content Field handlers to enforce validation in the content API, and please help the community to decide whether to merge the Responsive Admin Theme or not. Check out our last post for this year!

Orchard Core updates

Fluid.Core 2.3.0

The 2.3.0 version of Fluid.Core is here and merged into Orchard Core. Let's see some of the important changes in this version!

The first one is adding support for TimeSpan. Now, if you have a C# TimeSpan object that you pass in a model, it's converted to a DateTime starting from 1970.

The second one is adding replace_last and remove_last filters. These are standard Liquid filters that can now be used in Fluid as well.

Fluid now targets .NET 7.0. When you go to NuGet.org and search for the Fluid.Core package, you will see that the latest version of this package now also targets .NET 7.0.

The new version of Fluid.Core

Let's continue with the one about fixing the case/when tag multi-statements evaluation. In Shopify Liquid a case will return multiple expressions if multiple conditions are met. This can happen because a when can contain multiple values.

In Fluid the first condition that is true will return the expression and then exit the case in the same manner that a SQL "case" works. If you check out this screenshot, you can see the Liquid behavior on the Shopify API. Now Fluid supports this behavior.

Case/When tag multi-statements evaluation

Add Content Field handlers to enforce validation in the content API

When creating content using the Contents API, the content is stored as the user sends it without any kind of validation. For example, if you create a type with a required TitlePart, and post a new item with no title, the content item gets created with no title.

Here the goal was to implement the ValidatingAsync method in every part/field handler so that way, each part/field is validated against its own settings. Also, add field handlers to be called so we can validate fields. So, to summarize this addition, this is about adding a way to attach handlers for fields. For example:

services.AddContentField<TextField>()
.UseDisplayDriver<TextFieldDisplayDriver>()
.AddHandler<TextFieldHandler>(); // this was added
  • TitlePartHandler was modified to validate the part against the TitlePartSettings.
  • New handlers were added:
    • TextFieldHandler to validate a text field.
    • One handler for each part/field will be added "if it does not exist" which would implement that ValidatingAsync(...) event. This would be part of a follow-up PR to ensure the team is in agreement with the approach and to reduce the code change.

The new IContentFieldHandler interface

News from the community

Help the community decide whether to merge the Responsive Admin Theme or not

Last month you could see a demo of the Responsive Admin Theme where one can change the look of the forms.

Now we need to decide whether we want to merge this PR or not for the reasons explained in the meeting where the feature was demoed (and also in the meeting on 12/20/2022).

To vote please use reactions for this comment (not on a new comment please, but you can still comment on the PR on top of it).

The limit for the vote will be January 3rd, 2023. Thank you!

Responsive editors for the Content Parts

Christmas in Lombiq

Sometimes we do stuff. Together. Not (just) in front of computer screens. These are some usual events in Lombiq that are all announced and arranged in advance. We periodically have an event called RnDay: this is a few hour-long event where we share with each other what we recently worked on and what we plan to do. E.g., If we recently finished a project, then the project's team members demo what they've done. We had our last RnDay for this year in the Aranytíz Budapest, which is an event space where we held this event. And at the end of the day, we visited a nearby restaurant to have dinner together.

We would like to thank you all for reading our posts and making the Orchard community stronger together with us! We hope that we can give you valuable news and demos about the happenings around Orchard and Orchard Core from time to time by reading our posts and of course the This week in Orchard newsletter. We would like to wish everyone a Merry Christmas and a Happy New Year with some photos of our latest event!

Lombiq RnDay 15

Orchard Harvest 2023

For those who are too young to remember, we had Orchard conferences, called Orchard Harvest. And the conference website was available under orchardharvest.org, but unfortunately, it's not anymore. The last one was in 2017 in New York. So, having another get-together is very much overdue. If you would like to see or get a feeling of how this looked like before, we have a couple of mood videos on the Orchard YouTube channel, like this one from the first conference.

The point is that we should really think about organizing the next one, and we at Lombiq can take part in that or provide an organizing role with anybody who wants to take part. If you have any feedback or you are looking forward to having a Harvest again, please share your opinion with us by filling out this survey about the upcoming Orchard Harvest!

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 379 subscribers! We have started this newsletter to inform the community around Orchard of the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.

Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!

If you are interested in more news about Orchard and the details of the topics above, don't forget to check out the recording of this Orchard meeting!

No Comments

Add a Comment