# Property Validation

Property values entered are validated against their type. Optional validation expressions need to be specified in JavaScript where the property value is referred as *`_this.value`.* The expressions need to be evaluated to a boolean value (`true|false`). Examples:

* Only uppercase values are valid for strings: `_this.value == _this.value.toUpperCase()`
* Only numbers larger than 10 are valid: `_this.value > 10`
* Date value needs to be after 2016-12-04 12:45:30: `_this.value.isAfter(java.time.LocalDateTime.parse(\"2016-12-04T12:45:30\")`
* Valid email string: `/\S+@\S+/.test("_this.value")`

In case the validation fails for the value entered in the **Local Code Editor**, the defined validation message is presented to the user. The value entered can be referenced using the `%s` specifier. For example, typing the value `MyString` for a string type Local Code property where the property definition's validation expression and message are

* `_this.value == _this.value.toUpperCase()`
* `Only upper case letters are allowed. '%s' has lowercase letters`,

will result in the message *Only upper case letters are allowed. '`'MyString'` has lowercase letters.*

![String type property validation](https://snowowl.atlassian.net/wiki/download/thumbnails/1198358541/06.png?version=1\&modificationDate=1602684589372\&cacheVersion=1\&api=v2\&width=750)

### Editing property definitions

A new property definition can be added to a Local Code System by pressing the **`+`** button located in the *Additional properties* the section toolbar and selecting the type of the property. The attributes of the new property can be set using the editor. User-defined properties on the **Local Code Editor** are presented in the order of the corresponding property definitions configured on the **Local Code System Editor**. The order of the definitions can be rearranged using the arrow buttons located on the property definition section headers. The detailed definition of a property can be collapsed individually or by pressing the **`Collapse All`** button on the section toolbar. Pressing the **`Expand All`** button shows the details of all the property definitions. To remove the property, the **`X`** button located on the section toolbar needs to be pressed.&#x20;

{% hint style="danger" %}
Removing a property definition from a Local Code System will result in removing all the corresponding properties from every Local Code under the Local Code System.&#x20;
{% endhint %}

{% hint style="success" %}
To persist the changes, the **Local Code System Editor** needs to be saved.
{% endhint %}
