StringConstraint

class StringConstraint : Constraint


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

Summary

Constants

const Int
const Int

Public constructors

StringConstraint(allowedSet: Set<String>, isCaseSensitive: Boolean)
StringConstraint(
    allowedSet: Set<String>,
    isCaseSensitive: Boolean,
    synonyms: Map<StringList<String>>
)
StringConstraint(
    disallowedSet: Set<String>,
    minLength: Int,
    maxLength: Int,
    isCaseSensitive: Boolean,
    regex: Regex?
)

Public properties

Set<String>?

The allowed values.

Set<String>

The disallowed values.

Boolean

Whether the constraint is case sensitive.

Int

The maximum length of the string.

Int

The minimum length of the string.

Regex?

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

Map<StringList<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.

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: Set<String>

The set of allowed values.

StringConstraint

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

The set of allowed values.

isCaseSensitive: Boolean = false

Whether the constraint is case sensitive.

synonyms: Map<StringList<String>>

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: Set<String>

The set of disallowed values.

minLength: Int = MIN_STRING_LENGTH

The minimum length of the string.

maxLength: Int = MAX_STRING_LENGTH

The maximum length of the string.

regex: Regex? = 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 allowedSetSet<String>?

The allowed values.

disallowedSet

val disallowedSetSet<String>

The disallowed values.

isCaseSensitive

val isCaseSensitiveBoolean

Whether the constraint is case sensitive.

maxLength

val maxLengthInt

The maximum length of the string.

minLength

val minLengthInt

The minimum length of the string.

regex

val regexRegex?

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

synonyms

val synonymsMap<StringList<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.