Should not allow to create "regularExpression" validation if pattern is invalid

Fixed in

EPiServer.CMS.Core 11.20.5

Created

Jan 07, 2021

Updated

Feb 23, 2021

Area

CMS Core

State

Closed, Fixed and tested


Description

Steps to reproduce:
Define a content type via Definitions Api.
Note: A "regularExpression" validation is added to a string property but its pattern is invalid. For example, "pattern": "[0-9]++"

{
	"name": "PageRegExValidationInvalidCase3",
	"baseType": "Page",
	"editSettings": {
		"available": true,
		"order": 0
	},
	"properties": [
        {
			"name": "String1",
			"dataType": "PropertyString",
			"validation": [
				{
					"name": "RegularExpression",
					"severity": "error",
                    "pattern": "[0-9]++",
					"errorMessage": "String 1: pattern is invalid"

				}
			]
		},
        {
			"name": "StringList1",
			"dataType": "PropertyStringList",
			"validation": [
				{
					"name": "itemRegularExpression",
					"severity": "error",
                    "pattern": "[0-9]++",
					"errorMessage": "String List 1: pattern is invalid"

				}
			]
		}
	]
}

Expected result: 
Content management is created with invalid pattern return 400- Bad Request.

Actual result:
Content type is created with invalid pattern. 

Content management is created with invalid pattern return 500.