# Data Extensions



Overview [#overview]

Accounts, elements, etc. can be extended with custom data properties. These entities will include a `data` property when accessed through the API or plugins, which contains data that was set for the entity in accordance with the configuration. For example, a `vehicle` element might have the following configuration:

```json
{
  "data": {
    {
      "name": "make",
      "type": "string",
      "scope": "Q,P"
    },
    {
      "name": "model",
      "type": "string",
      "scope": "Q,P"
    },
    {
      "name": "year",
      "type": "int",
      "scope": "Q,P"
    },
    {
      "name": "vin",
      "type": "string",
      "scope": "Q,P"
    }
  }
}
```

When that element is created it might then have the following contents:

```json
{
	"data": {
		"make": "Toyota",
		"model": "Camry",
		"year": 2020,
		"vin": "4T1M11AK9LU893499"
	}
}
```

<span id="data-scopes" />

Data Scopes [#data-scopes]

Each data property has an associated scope. In configuration, the scope is specified with a string such as `"scope": "Q, P"`. These are the `scope` options:

* `QQ`: The property is associated with [Quick Quotes](/features/policy-quotation/quick-quotes)
* `Q`: The property is associated with Quotes
* `P`: The property is associated with Policies

Because quotes must have all the data required to issue a policy, a data scope of `P` must also have `Q`.

Data Types [#data-types]

Each property is declared with a data type. There are several built-in data types that be used, or you may define your own custom types. See the [Data Extension Types](/configuration/data-extensions/data-extension-types) topic for details.

<Callout>
  If the type is not specified for a given data property, the default of `string` will be used.
</Callout>

Quantifiers and Arrays [#quantifiers-and-arrays]

Each property type may be modified by the use of a [quantifier](/configuration/general-topics/quantifiers), which specifies how many of the given value the property may store. The valid quantifiers for a data extension property type are:

* (no suffix): The value is scalar and not `null` (i.e. it has exactly one value)
* `?`: The value is scalar but may be `null`
* `+`: The value is an array with *one or more* values of the given type
* `*`: The value is an array with *any number* of values of the given type

If you have a property with base type `int`, which can store an integer, the type could be declared as any of:

* `int`: `0`, `42`, and `-13` are all valid values, but `null` is not
* `int?`: Like `int` but also allows `null`
* `int+`: `[0, 1]`, and `[-13, 42, 103]` are valid values.
* `int*`: `[]`, `[0, 1]`, and `[-13, 42, 103]` are valid values. Note that the `*` does not permit a `null` array; but the array can be empty.

Validation Requirements [#validation-requirements]

You may specify additional requirements for data properties:

| Property    | Applicable Type(s) | Details                                                         |
| ----------- | ------------------ | --------------------------------------------------------------- |
| `min`       | numerical          | The minimum allowed value.                                      |
| `max`       | numerical          | The maximum allowed value.                                      |
| `minLength` | strings            | The minimum string length.                                      |
| `maxLength` | strings            | The maximum string length.                                      |
| `regex`     | strings            | The regular expression pattern to which the value must conform. |
| `options`   | strings            | The array of strings from which the value may be selected.      |

`regex` provides powerful basic validation that the platform can enforce for you; for example, you may use a regex pattern to specify the acceptable shape for a string representing a legal identifier in a particular locale:

```json
{
	"data": {
		"insureds_socialSecurityNumber": {
			"displayName": "Social Security Number",
			"type": "string",
			"regex": "[0-9]{3}[-][0-9]{2}[-][0-9]{4}",
			"maxLength": 11
		}
	}
}
```

Other Data Properties [#other-data-properties]

You may add additional properties to your data:

| Property       | Applicable Type(s) | Details                                                                              |
| -------------- | ------------------ | ------------------------------------------------------------------------------------ |
| `tag`          | all                | An array of metadata strings for all fields - generally consumed by UI clients.      |
| `precision`    | long \| decimal    | An integer specifying the number of places to persist floating point numeric values. |
| `roundingMode` | long \| decimal    | The rounding mode to be employed when rounding of the value is invoked.              |
| `defaultValue` | all                | The value to be used if a required field is absent upon validation.                  |

```json
{
  "data": {
    "vechile_class_risk_factor": {
      "type": "decimal",
      "max": "1",
      "min": "0",
      "precision": 7,
      "roundingMode": "halfUp",
      "tag": ["tab1", "uneditable"]
    }
  }
```

Comprehensive Properties List [#comprehensive-properties-list]

* `displayName`
* `type`
* `scope`
* `defaultValue`
* `min`
* `max`
* `minLength`
* `maxLength`
* `precision`
* `roundingMode`
* `options`
* `regex`
* `tag`

See Also [#see-also]

* [Data Extension Types](/configuration/data-extensions/data-extension-types)
* [Identifiers](/configuration/general-topics/identifiers)
* [Quantifiers](/configuration/general-topics/quantifiers)
