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(
    disallowedSet: Set<String>,
    minLength: Int,
    maxLength: Int,
    isCaseSensitive: Boolean,
    regex: Regex?
)

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(
    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>?

disallowedSet

val disallowedSetSet<String>

isCaseSensitive

val isCaseSensitiveBoolean

maxLength

val maxLengthInt

minLength

val minLengthInt

regex

val regexRegex?