---
title: "The Plugin.Validation.PolicySet"
slug: "the-plugin-validation-policyset"
abstract: "Commerce EngineがBusiness ToolsやAPIリクエストで入力された値を検証するために使用するデフォルトの検証ポリシー群を説明し一覧化しています。"
---
# The Plugin.Validation.PolicySet

Plugin.Validation.PolicySet.jsonファイルは、Business ToolsまたはAPI呼び出しを通じて入力された構成値に対してCommerce Engineが強制する検証ポリシーのグループを定義しています。

検証ポリシーは、Commerceエンティティプロパティまたはエンティティコンポーネントプロパティに適用されます。

Commerce Engine SDK.\*.zipパッケージでは、サンプルSitecore.Commerce.Engineソリューションで提供されているデフォルトのポリシーセットJSONファイルを見ることができます。デフォルトのポリシーセットファイルへのパスは以下の通りです:

wwwroot\\data\\Environments\\Plugin.Validation.PolicySet-1.0.0.json

## 検証ポリシーの例

以下は、Customer entityプロパティにデフォルトで適用される検証ポリシーの例を示しています:

"$type": "Sitecore.Commerce.Core.ValidationPolicy, Sitecore.Commerce.Core",
 "TypeFullName": "Sitecore.Commerce.Plugin.Customers.Customer",
 "Models": {
 "$type": "System.Collections.Generic.List\`1Sitecore.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
 }
 
 }
 },

## 検証ポリシーの特性

Sitecore.Commerce.Core.ValidationAttributesモデルは、Commerce Engineが検証ポリシーを定義するためにサポートする検証プロパティを定義します。

これらのプロパティのいずれかを使って [カスタム検証ポリシーを定義](https://doc.sitecore.com/xp/ja/developers/103/sitecore-experience-commerce/add-a-validation-policy-to-control-configuration-data-input.html "Add a validation policy to control configuration data input")できます。

> !注これらのプロパティの一部は、現在デフォルトの検証ポリシーセットで使用されていません。

財産

概要

MinLength                                      

有効なプロパティ値に必要な最小文字数。

MaxLength

有効なプロパティ値で許される最大文字数。

MinValue

これは最低財産価値を表す整数です。

MaxValue

これは最大の財産価値を表す整数です。

StartDate

開始日はある日程内です。

EndDate

日付範囲内の終了日。

RegexValidator

入力文字の列を比較するための正則表現です。例えば、Customer "email" プロパティ値はデフォルトで以下の正規表現に対して検証されます:("^\\\\w-\\\\.+@(\\\\w-+\\\\.)+\\\\w-{2,4}$")

RegexValidatorErrorCode

定義された商取引用語の値に対応するエラーコードがエラーメッセージとして表示されます。  
  
Customer\_EmailValidationError*はあらかじめ定義された商取引用語で、「メールは有効でない」という表示値を持ちます。*

CustomValidator

カスタムバリデーターです。