Interface NonEmptyStringOptions

The options for a NonEmptyString:

  • range? - a list of other strings or an enum the string has to match
  • regex?: RegExp - a regular expression the string has to match
  • min?: number - minimum required length of the string
  • max?: number - maximum allowed length of the string

Hierarchy

Properties

Properties

max?: number

the upper bound of the interval the value has to be in

min?: number

the lower bound of the interval the value has to be in

name?: string

the name of the ValueObject to identify in a possible ErrorMessage.

  • eg: 'MealPlan.price'
range?: string[] | readonly string[] | {
    [s: string]: string | number;
} | {
    [s: number]: string;
}

a string[] or enum of all possible values the given value can match.

  • for enums the keys as well as the values will be looked up to match!
  • technically its possible to use any kind of object that has strings as keys and/or values

Example

const stringArray = ['first', 'second', ...];

enum NumericEnum {
first, second, ...
}

enum AlsoNumericEnum {
first = 1, second = 2, ...
}

enum StringEnum {
first = 'first', second = 'second', ...
}

enum HeterogenousEnum {
first = 1, second = 'second', ...
}
regex?: RegExp

a regular expression the given value must match

Generated using TypeDoc