AssertCondition 정책은 요청 또는 응답 흐름에서 조건부 문을 평가합니다. 흐름 변수를 기반으로 조건을 정의하고 이 정책을 사용하여 조건을 어설션할 수 있습니다. 조건은 항상 부울 값(true 또는 false)으로 평가됩니다. 조건문 작성에 대한 자세한 내용은 조건 참조를 확인하세요.
조건을 평가한 후 AssertCondition 정책은 assertcondition.policy-name.truthValue 흐름 변수에 평가 결과를 저장합니다.
후속 콜아웃 또는 조정된 로직에서 결과 흐름 변수를 사용할 수 있습니다.
조건이 true로 평가되면 변수 값이 true로 설정되고 그렇지 않으면 false로 설정됩니다. 여러 AssertCondition 정책을 정의한 경우 변수 이름의 policy-name을 통해 변수를 고유하게 식별할 수 있습니다.
이 정책은 표준 정책이며 모든 환경 유형에 배포할 수 있습니다. 정책 유형과 각 환경 유형에서의 가용성에 대한 자세한 내용은 정책 유형을 참조하세요.
<AssertCondition>
<AssertCondition> 정책을 정의합니다. 이 정책을 사용하면 논리 연산자로 연결된 하나 이상의 조건이 있는 조건문을 평가할 수 있습니다. 조건에서 지원되는 모든 연산자에 대한 자세한 내용은 연산자를 참조하세요.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssertCondition">
<!-- Display name for this policy -->
<DisplayName>DISPLAY_NAME</DisplayName>
<!-- Assertion's condition where operators are defined -->
<Condition>CONDITIONAL_STATEMENT</Condition>
</AssertCondition>
예
다음 예시에서는 google.dialogflow.my-prefix.claimAmount 변수가 0보다 크고 1000보다 작은지 확인합니다.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssertCondition continueOnError="false" enabled="true"
name="MyAssertCondition">
<DisplayName>Assert My Condition</DisplayName>
<Condition>(google.dialogflow.my-prefix.claimAmount > 0)
and
(google.dialogflow.my-prefix.claimAmount LesserThan 1000)</Condition>
</AssertCondition>
예를 들면 다음과 같습니다.
google.dialogflow.my-prefix.claimAmount 변수 값이 500이면 조건이 참으로 평가되므로 assertcondition.MyAssertCondition.truthValue 변수가 true로 설정됩니다.
그러나 google.dialogflow.my-prefix.claimAmount 변수 값이 1200이면 assertcondition.MyAssertCondition.truthValue 변수는 false로 설정됩니다.
이 요소에는 다음과 같이 모든 정책에 공통된 속성이 있습니다.
속성
기본값
필수 여부
설명
name
해당 없음
필수
정책의 내부 이름입니다. name 속성의 값에는 문자, 숫자, 공백, 하이픈, 밑줄, 마침표가 포함될 수 있습니다. 이 값은 255자(영문 기준)를 초과할 수 없습니다.
원하는 경우 <DisplayName> 요소를 사용하여 관리 UI 프록시 편집기의 정책에 다른 자연어 이름을 사용하여 정책에 라벨을 지정합니다.
continueOnError
거짓
선택사항
정책이 실패할 경우 오류가 반환되도록 하려면 false로 설정합니다. 이는 대부분의 정책에서 예상되는 동작입니다. 정책이 실패해도 흐름 실행이 계속되도록 하려면 true로 설정합니다. 참조:
이 섹션에서는 반환되는 오류 코드 및 오류 메시지와 이 정책이 오류를 트리거할 때 Apigee에서 설정한 오류 변수를 설명합니다.
오류를 처리하기 위해 오류 규칙을 개발 중인 경우, 이 정보는 중요합니다. 자세한 내용은 정책 오류에 대해 알아야 할 사항 및 오류 처리를 참조하세요.
런타임 오류
이러한 오류는 정책이 실행될 때 발생할 수 있습니다.
오류 코드
HTTP 상태
원인
steps.assertcondition.ConditionEvaluationFailed
500
조건문을 평가하지 못했습니다. 런타임 시 변수에 잘못된 값이 포함된 경우 등 이 오류가 발생하는 이유는 다양합니다.
배포 오류
이 오류는 이 정책이 포함된 프록시를 배포할 때 발생할 수 있습니다.
오류 이름
원인
InvalidCondition
정책에서 조건문의 유효성을 검사할 수 없습니다. 잘못된 조건 또는 지원되지 않는 연산자 사용을 포함한 여러 이유로 이 오류가 발생할 수 있습니다.
오류 변수
정책에 실행 오류가 발생할 때마다 Apigee는 오류 메시지를 생성합니다. 오류 응답에서 이러한 오류 메시지를 볼 수 있습니다. 시스템에서 생성된 오류 메시지가 제품의 컨텍스트와 관련이 없을 경우가 많습니다. 메시지를 보다 의미 있게 만들기 위해 오류 유형에 따라 오류 메시지를 맞춤설정할 수 있습니다.
오류 메시지를 맞춤설정하려면 오류 규칙 또는 RaiseFault 정책을 사용하면 됩니다. 오류 규칙과 RaiseFault 정책의 차이점에 대한 자세한 내용은 FaultRules와 RaiseFault 정책 비교를 참조하세요.
오류 규칙과 RaiseFault 정책 모두에서 Condition 요소를 사용하여 조건을 확인해야 합니다.
Apigee는 각 정책에 고유한 오류 변수를 제공하며 정책이 런타임 오류를 트리거할 때 오류 변수 값이 설정됩니다.
이러한 변수를 사용하여 특정 오류 조건을 확인하고 적절한 조치를 취할 수 있습니다. 오류 조건 확인에 대한 자세한 내용은 빌드 조건을 참조하세요.
다음 표에서는 이 정책과 관련된 오류 변수를 설명합니다.
변수
장소
예
fault.name="FAULT_NAME"
FAULT_NAME은 런타임 오류 표에 나열된 오류 이름입니다.
오류 이름은 오류 코드의 마지막 부분입니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-05(UTC)"],[[["\u003cp\u003eThe AssertCondition policy in Apigee and Apigee hybrid evaluates a conditional statement based on flow variables in request or response flows, determining if it's true or false.\u003c/p\u003e\n"],["\u003cp\u003eThe result of the conditional evaluation is stored in the \u003ccode\u003eassertcondition.\u003c/code\u003e\u003cvar translate=no\u003epolicy-name\u003c/var\u003e\u003ccode\u003e.truthValue\u003c/code\u003e flow variable, which can be used in subsequent operations within the flow.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003e<AssertCondition>\u003c/code\u003e element, a key part of this policy, allows for defining a conditional statement using one or more conditions joined by logical operators.\u003c/p\u003e\n"],["\u003cp\u003eThe policy has attributes like \u003ccode\u003ename\u003c/code\u003e, \u003ccode\u003econtinueOnError\u003c/code\u003e, and \u003ccode\u003eenabled\u003c/code\u003e, which control its behavior and can be set to customize the error response or enable/disable the policy.\u003c/p\u003e\n"],["\u003cp\u003eRuntime and deployment errors, such as \u003ccode\u003esteps.assertcondition.ConditionEvaluationFailed\u003c/code\u003e and \u003ccode\u003eInvalidCondition\u003c/code\u003e, can occur and are associated with specific fault codes and fault variables for error handling.\u003c/p\u003e\n"]]],[],null,["# AssertCondition policy\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nOverview\n--------\n\n\nThe AssertCondition policy evaluates a conditional statement at runtime in the\nrequest or response flows. You can define a condition based on the flow variables,\nand use this policy to assert the condition. A condition always evaluates to a\nboolean value, either true or false. For more information about writing a conditional statement, see\n[Conditions reference](/apigee/docs/api-platform/reference/conditions-reference).\n\nAfter evaluating the condition, the AssertCondition policy stores the result of\nthe evaluation in the `assertcondition.`\u003cvar translate=\"no\"\u003epolicy-name\u003c/var\u003e`.truthValue` flow variable.\nYou can use the resultant flow variable in your subsequent callouts or orchestrated logic.\nIf a condition evaluates to true, the value of the variable is set to\n`true`, `false` otherwise. If you have defined multiple\nAssertCondition policies, the `policy-name` in the\nvariable name helps you to uniquely identify the variable.\n\nThis policy is a *Standard policy* and can be deployed to any environment type. For\ninformation on policy types and availability with each environment type, see\n[Policy types](/apigee/docs/api-platform/reference/policies/reference-overview-policy#policy-types).\n\n`\u003cAssertCondition\u003e`\n-------------------\n\nDefines an `\u003cAssertCondition\u003e` policy. By using this policy, you can evaluate a\nconditional statement that has one or more conditions joined by a logical operator. For information\nabout all the supported operators in a condition, see [Operators](/apigee/docs/api-platform/reference/conditions-reference#operators).\nThe result of a conditional statement is a boolean which can be either a `true` or a `false`.\n\nThe following table provides a high-level description of the child elements of [`\u003cAssertCondition\u003e`](/apigee/docs/api-platform/reference/policies/assert-condition-policy#assertcondition):\n\nThe `\u003cAssertCondition\u003e` element uses the following syntax: \n\n### Syntax\n\n```scdoc\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003cAssertCondition\"\u003e\n \u003c!-- Display name for this policy --\u003e\n \u003cDisplayName\u003eDISPLAY_NAME\u003c/DisplayName\u003e\n \u003c!-- Assertion's condition where operators are defined --\u003e\n \u003cCondition\u003eCONDITIONAL_STATEMENT\u003c/Condition\u003e\n\u003c/AssertCondition\u003e\n```\n\n### Example\n\nThe following example checks if the `google.dialogflow.my-prefix.claimAmount` variable is greater\nthan 0 and less than 1000. \n\n```text\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n\u003cAssertCondition continueOnError=\"false\" enabled=\"true\"\n name=\"MyAssertCondition\"\u003e\n \u003cDisplayName\u003eAssert My Condition\u003c/DisplayName\u003e\n \u003cCondition\u003e(google.dialogflow.my-prefix.claimAmount \u003e 0)\n and\n (google.dialogflow.my-prefix.claimAmount LesserThan 1000)\u003c/Condition\u003e\n\u003c/AssertCondition\u003e\n```\n\nIn this example:\n\n- If the value of `google.dialogflow.my-prefix.claimAmount` variable is 500, the condition evaluates to true and hence the `assertcondition.MyAssertCondition.truthValue` variable is set to `true`.\n- However, if the value of the `google.dialogflow.my-prefix.claimAmount` variable is 1200, the `assertcondition.MyAssertCondition.truthValue` variable is set to `false`.\n\nThis element has the following attributes that are common to all policies:\n\nChild element reference\n-----------------------\n\nThis section describes the child elements of [`\u003cAssertCondition\u003e`](/apigee/docs/api-platform/reference/policies/assert-condition-policy#assertcondition).\n\n### `\u003cCondition\u003e`\n\nSpecifies the condition to evaluate. For more information\nabout writing a conditional statement in Apigee, see\n[Conditions reference](/apigee/docs/api-platform/reference/conditions-reference).\n\n### `\u003cDisplayName\u003e`\n\nUse in addition to the `name` attribute to label the policy in the\nmanagement UI proxy editor with a different, more natural-sounding name.\n\nThe `\u003cDisplayName\u003e` element is common to all policies.\n\nThe `\u003cDisplayName\u003e` element uses the following syntax: \n\n### Syntax\n\n```scdoc\n\u003cPolicyElement\u003e\n \u003cDisplayName\u003e\u003cvar translate=\"no\"\u003ePOLICY_DISPLAY_NAME\u003c/var\u003e\u003c/DisplayName\u003e\n ...\n\u003c/PolicyElement\u003e\n```\n\n### Example\n\n```text\n\u003cPolicyElement\u003e\n \u003cDisplayName\u003eMy Validation Policy\u003c/DisplayName\u003e\n\u003c/PolicyElement\u003e\n```\n\nThe `\u003cDisplayName\u003e` element has no attributes or child elements.\n\nError codes\n-----------\n\n\nThis section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error.\nThis information is important to know if you are developing fault rules to\nhandle faults. To learn more, see [What you need to know\nabout policy errors](/apigee/docs/api-platform/fundamentals/what-you-need-know-about-policy-errors) and [Handling\nfaults](/apigee/docs/api-platform/fundamentals/fault-handling).\n\n### Runtime errors\n\nThese errors can occur when the policy executes.\n\n### Deployment errors\n\nThese errors can occur when you deploy a proxy containing this policy.\n\n### Fault variables\n\nWhenever there are execution errors in a policy, Apigee generates error messages. You can view\nthese error messages in the error response. Many a time, system generated error messages might not be relevant\nin the context of your product. You might want to customize the error messages based on the\ntype of error to make the messages more meaningful.\n\nTo customize the error messages, you can use either fault rules or the RaiseFault policy. For\ninformation about differences between fault rules and the RaiseFault policy, see\n[FaultRules vs. the RaiseFault policy](/apigee/docs/api-platform/fundamentals/fault-handling#rulesvraisefault).\nYou must check for conditions using the `Condition` element in both the fault rules and the RaiseFault policy.\nApigee provides fault variables unique to each policy and the values of the fault variables are set when a policy triggers runtime errors.\nBy using these variables, you can check for specific error conditions and take appropriate actions. For more information about checking error\nconditions, see [Building conditions](/apigee/docs/api-platform/fundamentals/fault-handling#buildingconditions).\n\nThe following table describes the fault variables specific to this policy.\n\nFor more information about policy errors, see [What you\nneed to know about policy errors](/apigee/docs/api-platform/fundamentals/what-you-need-know-about-policy-errors).\n\n\u003cbr /\u003e"]]