The Plugin.Validation.PolicySet

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

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エンティティ プロパティに既定で適用される検証ポリシーの例を示します。

"$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
            }
          ]
        }
      },

検証ポリシーのプロパティ

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

これらのプロパティのいずれかを使用して 、カスタム検証ポリシーを定義できます

メモ

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

財産

形容

MinLength                                      

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

MaxLength

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

MinValue

最小プロパティ値を表す整数。

MaxValue

プロパティの最大値を表す整数。

StartDate

日付範囲内の開始日。

EndDate

日付範囲内の終了日。

RegexValidator

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

RegexValidatorErrorCode

エラー メッセージとして表示する定義済みの商取引用語値に対応するエラー コード。

たとえば、値Customer_EmailValidationErrorは、次の表示値を持つ定義済みのコマース用語です。 "Email is not valid."

CustomValidator

カスタムバリデーター。

この記事を改善するための提案がある場合は、 お知らせください!