# StringConstraint


```
class StringConstraint : Constraint
```

<br />

*** ** * ** ***

Represents string constraints, including constraints on length, and specific allowed and disallowed values.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#MAX_STRING_LENGTH() = 256` |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#MIN_STRING_LENGTH() = 0` |

| ### Public constructors |
|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#StringConstraint(kotlin.collections.Set,kotlin.Boolean)(allowedSet: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>, isCaseSensitive: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` |
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#StringConstraint(kotlin.collections.Set,kotlin.Boolean,kotlin.collections.Map)( allowedSet: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>, isCaseSensitive: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, synonyms: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>> )` |
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#StringConstraint(kotlin.collections.Set,kotlin.Int,kotlin.Int,kotlin.Boolean,kotlin.text.Regex)( disallowedSet: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>, minLength: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, maxLength: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, isCaseSensitive: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, regex: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/index.html? )` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>?` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#allowedSet()` The allowed values. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#disallowedSet()` The disallowed values. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#isCaseSensitive()` Whether the constraint is case sensitive. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#maxLength()` The maximum length of the string. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#minLength()` The minimum length of the string. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/index.html?` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#regex()` A regular expression constraining the range of values allowed for the string. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>>?` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StringConstraint#synonyms()` For allowed set based constraints, when specified, the key is the allowed value and the value is a list of user-friendly names for that value. |

## Constants

### MAX_STRING_LENGTH

```
const val MAX_STRING_LENGTH = 256: Int
```

### MIN_STRING_LENGTH

```
const val MIN_STRING_LENGTH = 0: Int
```

## Public constructors

### StringConstraint

```
StringConstraint(allowedSet: Set<String>, isCaseSensitive: Boolean = false)
```

| Parameters |
|---|---|
| `allowedSet: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | The set of allowed values. |

### StringConstraint

```
StringConstraint(
    allowedSet: Set<String>,
    isCaseSensitive: Boolean = false,
    synonyms: Map<String, List<String>>
)
```

| Parameters |
|---|---|
| `allowedSet: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | The set of allowed values. |
| `isCaseSensitive: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html = false` | Whether the constraint is case sensitive. |
| `synonyms: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>>` | For allowed set based constraints the key is the allowed value and the value is a list of user-friendly names for that value. |

### StringConstraint

```
StringConstraint(
    disallowedSet: Set<String>,
    minLength: Int = MIN_STRING_LENGTH,
    maxLength: Int = MAX_STRING_LENGTH,
    isCaseSensitive: Boolean = false,
    regex: Regex? = null
)
```

| Parameters |
|---|---|
| `disallowedSet: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | The set of disallowed values. |
| `minLength: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html = MIN_STRING_LENGTH` | The minimum length of the string. |
| `maxLength: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html = MAX_STRING_LENGTH` | The maximum length of the string. |
| `regex: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-regex/index.html? = null` | A regular expression constraining the range of values allowed for the string. constructor Create a `StringConstraint` instance based on a combination of one or more of: - a set of disallowed values - a mininmum length - a maximum length - a regular expression pattern |

## Public properties

### allowedSet

```
val allowedSet: Set<String>?
```

The allowed values.

### disallowedSet

```
val disallowedSet: Set<String>
```

The disallowed values.

### isCaseSensitive

```
val isCaseSensitive: Boolean
```

Whether the constraint is case sensitive.

### maxLength

```
val maxLength: Int
```

The maximum length of the string.

### minLength

```
val minLength: Int
```

The minimum length of the string.

### regex

```
val regex: Regex?
```

A regular expression constraining the range of values allowed for the string.

### synonyms

```
val synonyms: Map<String, List<String>>?
```

For allowed set based constraints, when specified, the key is the allowed value and the value is a list of user-friendly names for that value.