# @if

* 하지만 조건에 따라 다른 행동을 취할 때 사용해요.

ex) 현재 유저의 구독 상태가 미구독일 경우 에러를 던져 로직 실행을 멈춰 구독 유저만 실행될 수 있도록 하기,  유저가 작성한 커뮤니티 글이 있을 경우 커뮤니티 글 작성 배지를 부여하기 등

* 조건을 설정하여 조건을 만족하면 True를 반환하며, 그렇지 않을 경우 False를 반환해요.

**사용 방법**

<figure><img src="/files/okFJdGlBM6jlmfWeHQXb" alt=""><figcaption></figcaption></figure>

1. 로직 설정 ➡︎ If When, Where에 원하는 값 입력 ➡︎ New data query 를 펼쳐 주세요. &#x20;
2. Event에서 @if를 드래그앤드롭하여 원하는 위치(flows, #ifTrue, #ifFalse, @for)에 넣어주세요.
3. Condition에서 원하는 조건을 드래그앤드롭하여, @if 내부 #condition 폴더로 넣어 조건을 설정할 수 있어요. 조건은 여러 개를 사용할 수 있어요.
4. \#condition에는 조건이 들어가요. 복수의 조건을 사용할 수 있으며, 복수의 조건을 전부 만족할 시 True를 반환하며 그렇지 않을 경우 False를 반환해요.
5. \#ifTrue에는 #condition 조건에 맞을 경우 실행할 명령을 입력해요.
6. \#ifFalse에는 #condition 조건에 맞지 않을 경우 실행할 명령을 입력해요.

<figure><img src="/files/BHcpoCF033OECFnBNjuV" alt=""><figcaption></figcaption></figure>

* \#eq : 위의 이미지와 같이 #left(좌 항)와 #right(우 항)에 비교할 값을 넣어주세요.
* \#isEmpty일 경우 동적 키 값이 빈 List인지 확인해 주세요.

\
**필드 설명**

* \#condition(List) (필수)\
  조건 연산자예요. \
  복수의 조건을 사용할 수 있으며 복수의 조건을 전부 만족할 시 True를 반환하며 그렇지 않을 경우 False를 반환해요.
* condition 연산자 종류

  * eq : 좌 항과 우 항이 같은지 확인해요.

  * ne : 좌 항과 우 항이 다른지 확인해요.

  * in : 우 항에 좌 항이 포함되는지 확인해요.

  * nin : 좌 항에 우 항이 포함하지 않는지 확인해요.

  * gt : 좌 항이 우 항보다 큰지 확인해요.

  * gte : 좌 항이 우 항보다 크거나 같은지 확인해요.

  * lt : 좌 항이 우 항보다 작은지 확인해요.

  * lte : 좌 항이 우 항보다 작거나 같은지 확인해요.

  * isEmpty : 동적 키 값이 null 이거나 빈 List 인지 확인해요.

  * regex : 좌 항에 정규 표현식을 적었을 때 우 항의 값이 좌 항의 정규 표현식에 맞는지 확인해요.&#x20;

  > 정규 표현식이란 문자열에서 특정한 패턴을 찾거나 대조하는데 사용되는 표현식이에요.
* \#ifTrue(List) (선택)
  * \#condition의 결과가 True일 때 #ifTrue에 있는 로직을 수행해요.
* \#ifFalse(List) (선택)
  * \#condition의 결과가 False일 때 #ifFalse에 있는 로직을 수행해요.

2024.01.16 Jinny


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ohmyapp.io/main/guide/develop_app/command-execute-function/create-logic/conditions/detailed-processing-conditions/if.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
