# Telosys directives

In addition to the standard Velocity language syntax, Telosys provides some specific "directives".&#x20;

These directives can be useful to simplify writing or debugging templates.

## #assertFalse

( Telosys specific directive - since version 2.0.7 )

Checks that the value of the first argument is FALSE.\
Otherwise throws an error with the given message.

Examples :

```velocity
 #assertFalse( $flag, "Flag is true (false expected)" ) 
 #assertFalse( $entity.hasCompositePrimaryKey(), "Composite Primary Key not supported" ) 
```

## #assertTrue

( Telosys specific directive - since version 2.0.7 )

Checks that the value of the first argument is TRUE.\
Otherwise throws an error with the given message.

Examples :

```velocity
 #assertTrue( $flag, "Flag is not true!" ) 
 #assertTrue( $entity.hasPrimaryKey(), "Primary Key required!" )
```

## #cancel

( Telosys specific directive - since version 3.3.0 )

Cancels the current generation. \
When "#cancel" is used in a template the target file is not generated. This directive is useful when certain entities are not supposed to be generated. A cancellation is not considered as an error (no reported in errors).

This directive has only one argument: a message to indicate why the generation was canceled&#x20;

Examples :

```velocity
#if ( $entity.name.startsWith("Abcd") )
#cancel("No JPA class for this entity")
#end
```

## #checkId

( Telosys specific directive - since version 3.0.0 )

Checks the existence of ID/Primary Key in the given entity.\
Throws an error if there's no ID/Primary Key defined in the entity.

Examples :

```velocity
 #checkId( $entity) 
```

## #error

( Telosys specific directive - since version 2.0.7 )

Throws an error with the given message

Examples :

```velocity
 #if( $flag ) 
 #error( "Flag is true!" ) 
 #end 

 #if( ! $entity.hasPrimaryKey() ) 
 #error( "Primary Key required!" ) 
 #end 
```

## #using

( Telosys specific directive - since version 2.0.7 )

Declares that the current template will use unusual objects or variables which must therefore be defined in the context.\
This directive verifies that all required objects or variables are defined in the Velocity context.\
It throws an error if one of the given objects is not defined.\
Often used to verify that required specific variables have been defined.

Examples :

```velocity
 #using( "var1" ) 
 #using( "var1", "var2" ) 
 #using( "var1", "var2", "foo", "bar" ) 

 #using( '$var1' ) 
 #using( '$var1', '$var2' ) 
```


---

# 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://doc.telosys.org/bundles/telosys-directives.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.
