# `@values` annotation

The `@values` annotation is used to specify a set of permitted values for attributes.

## [](#_syntax)Syntax

Value annotation syntax

```typeql
<type label> value <value type> @values(value);
<type label> value <value type> @values(value0, value1, ..., valueN);
```

Ownership annotation syntax

```typeql
<type label> owns <attribute type label> @values(value0);
<type label> owns <attribute type label> @values(value0, value1, ..., valueN);
```

The `@values` annotation can be defined for either an attribute type’s value type or an ownership.

The `@values` annotation requires at least one argument. Multiple arguments can be specified, separated by commas. Arguments should be of the same value type as `<attribute type label>`. Please refer to [Supported value types](#_value_types) for the list of accepted value types.

## [](#_usage)Usage

The `@values` annotation adds a constraint on values of attributes of a given attribute type to be within the specified set of allowed values.

When defined for an attribute type’s value type, the annotation creates a constraint for any attribute of this attribute type.

```typeql
#!test[schema]
define
  attribute gender value string @values("male", "female", "other");
```

When defined for an ownership, the annotation creates a constraint for any attribute of this attribute type owned by the owner type. In the following example, an instance of the `emoji` type can contain any value, but a `reaction` can have (`has`) only the `emoji` s with the suitable values.

```typeql
#!test[schema]
#{{
define relation reaction relates parent;
#}}
#!test[schema]
define
  relation reaction owns emoji @values("like", "love", "funny", "surprise", "sad", "angry");
  attribute emoji value string;
```

### [](#_subtyping)Subtyping

The `values` constraint put on an attribute types' value type is inherited. This means that values of all subtypes of a constrained type are also constrained, and this constraint cannot be relaxed from the subtypes.

A subtype can introduce an even stricter constraint to allow only a subset of the inherited set of allowed values.

### [](#_subtyping_for_ownerships)Subtyping for ownerships

The `values` constraint put on an ownership should be respected by all the sub attribute types owned by this owner. This way, any instance of any subtype of the `emoji` [owned by](#_example_owns) any instance of any subtype of the `reaction` should comply to the defined `values`.

Ownerships of these subtypes can have their own `values` constraints, and they will be respected similarly down the inheritance line.

## [](#_limitations)Limitations

See [Supported value types](#_value_types) for the list of supported value types.

## [](#_references)References

### [](#_value_types)Supported value types

The `@values` annotation is applicable only to comparable value types, thus it is supported by all built-in TypeQL value types.

Table 1. Supported value types   

Value type

Supported?

Comment

`boolean`

✓

`integer`

✓

`double`

✓

`decimal`

✓

`string`

✓

`date`

✓

`datetime`

✓

`datetime-tz`

✓

`duration`

✓

[@unique](../unique/index.md) [@range](../range/index.md)

[Edit on GitHub](https://github.com/typedb/typedb-docs/edit/3.x-development/typeql-reference/modules/ROOT/pages/annotations/values.adoc) Edit this page on GitHub.