The Plugin.Validation.PolicySet
The Plugin.Validation.PolicySet.json
file defines a group of validation policies that the Commerce Engine enforces on some of the configuration input values entered using the Business Tools or via API calls.
The validation policies can apply to Commerce entity properties or to entity components properties.
In the Commerce Engine SDK.*.zip
package, you can see the default policy set JSON file provided in the sample Sitecore.Commerce.Engine
solution. The path to the default policy set file is:
wwwroot\data\Environments\Plugin.Validation.PolicySet-1.0.0.json
Example validation policies
The following shows an example of the validation policies applied by default to the Customer entity properties:
"$type": "Sitecore.Commerce.Core.ValidationPolicy, Sitecore.Commerce.Core",
"TypeFullName": "Sitecore.Commerce.Plugin.Customers.Customer",
"Models": {
"$type": "System.Collections.Generic.List`1[[Sitecore.Commerce.Core.Model, Sitecore.Commerce.Core]], mscorlib",
"$values": [
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "AccountNumber",
"MaxLength": 100,
"MinLength": 1
},
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "AccountStatus",
"MaxLength": 100,
"MinLength": 1
},
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "LoginName",
"MaxLength": 100,
"MinLength": 1
},
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "Email",
"MaxLength": 100,
"MinLength": 1,
"RegexValidator": "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$",
"RegexValidatorErrorCode": "Customer_EmailValidationError"
},
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "Password",
"MaxLength": 100
},
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "FirstName",
"MaxLength": 100
},
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "LastName",
"MaxLength": 100
},
{
"$type": "Sitecore.Commerce.Core.ValidationAttributes, Sitecore.Commerce.Core",
"Name": "Language",
"MaxLength": 100
}
]
}
},
Validation policy properties
The Sitecore.Commerce.Core.ValidationAttributes
model defines the validation properties that the Commerce Engine supports to define validation policies.
You can use any of these properties to define your custom validation policies.
Some of these properties are not currently used in the default validation policy set.
Property |
Description |
---|---|
|
The minimum number of characters required in a valid property value. |
|
The maximum number of characters allowed in a valid property value. |
|
An integer representing the minimum property value. |
|
An integer representing the maximum property value. |
|
The start date in a date range. |
|
The end date in a date range. |
|
The regular expressions against which to compare a sequences of input characters. For example, the Customer
|
|
The error code corresponding to a defined commerce term value to display as an error message. For example, the value |
|
A custom validator. |