Creating a custom rule to validate item fields

Being developers, we should provide an efficient interface to validate all information. Sitecore provides out-of-the-box validators that work both on the client side and server side, and also flexibility to create our own custom validators.

In this recipe, we will create an Employee Information form. Here, we will use some out-of-the-box validators to validate the required field, integer, and email. We will also create a custom validator to validate Employee Joining Date and Relieving Date.

How to do it…

We will first create a template with the required fields to achieve this recipe:

  1. Create an Employee template with fields such as Employee ID, Employee Name, Email Address, Date of Joining, and Date of ...

Get Sitecore Cookbook for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.