-
Notifications
You must be signed in to change notification settings - Fork 0
NonEmptyString
A String that is definitely a String that is not empty
-
↳
NonEmptyString
- equals
- toJSON
- create
- format
- fromList
- listEquals
- prefix
- toList
- validate
- validateInterval
- validateList
- validateNonEmptyString
- validateRange
- validateRegex
- validateString
• Protected new NonEmptyString(value)
| Name | Type |
|---|---|
value |
string |
valueObjects/string/NonEmptyString.ts:6
• Protected Readonly _value: string
the actual value of the ValueObject
• get value(): T
the actual value of this ValueObject
T
OptionalString.value
valueObjects/ValueObject.ts:13
▸ equals(obj): boolean
compares if the given value is either an equal ValueObject, or an equal value which would create an equal ValueObject
| Name | Type | Description |
|---|---|---|
obj |
string | NonEmptyString
|
to compare of equality |
boolean
valueObjects/string/NonEmptyString.ts:10
▸ toJSON(): string
this function is invoked by JSON.stringify() and converts the inner "_propertyKey" to "propertyKey"
string
the value
valueObjects/ValueObject.ts:61
▸ Static create(value, options?): NonEmptyString
| Name | Type | Description |
|---|---|---|
value |
string |
to create the ValueObject of |
options? |
NonEmptyStringOptions |
constraints the value has to fulfill |
the created ValueObject
valueObjects/string/NonEmptyString.ts:89
▸ Static Protected format(value, options?): string
Throws
Error if the formatting failed
| Name | Type | Description |
|---|---|---|
value |
string |
to be formatted with the given formatting options |
options? |
OptionalStringOptions |
constraints the value has to fulfill |
string
the formatted string
valueObjects/string/OptionalString.ts:70
▸ Static fromList(values, options?): NonEmptyString[]
| Name | Type | Description |
|---|---|---|
values |
undefined | string[] |
an array of primitives to map to an array of ValueObjects |
options? |
NonEmptyStringOptions & ListCreationOptions
|
constraints the values / list has to fulfill |
the array of ValueObjects
valueObjects/string/NonEmptyString.ts:98
▸ Static listEquals<ValueType>(a, b): boolean
compares 2 Lists of ValueObjects / values on equality
| Name |
|---|
ValueType |
| Name | Type | Description |
|---|---|---|
a |
ValueObject<ValueType>[] |
the list of ValueObjects to compare with |
b |
ValueObject<ValueType>[] | ValueType[] |
a list of ValueObjects / values for comparison |
boolean
true if the lists are equal
valueObjects/ValueObject.ts:29
▸ Static Protected prefix(options, addition?): string
constructs a prefix for possible error messages based on the ValueObjects name and an additional string:
- example for NonEmptyString with
name='Person':
"Person > NonEmptyString"| Name | Type | Default value | Description |
|---|---|---|---|
options |
undefined | CreationOptions
|
undefined |
the CreationOptions where the optional name: string is taken from |
addition |
string |
'' |
An additional name which will be added as "name.addition"
|
string
the name of the ValueObject
valueObjects/ValueObject.ts:77
▸ Static toList(values): string[]
| Name | Type | Description |
|---|---|---|
values |
NonEmptyString[] |
an array of ValueObjects to map to an array of their values |
string[]
the array of values
valueObjects/string/NonEmptyString.ts:109
▸ Static validate(value, options?): string
Throws
TypeError if not a string or empty
Throws
TypeError if the value doesn't fit the given enum
Throws
RangeError if the value is not matching the regex
Throws
RangeError if the value's length is not inside the interval
| Name | Type | Description |
|---|---|---|
value |
string |
to be validated as a not empty string with the corresponding constraints (options) |
options? |
NonEmptyStringOptions |
constraints the value has to fulfill |
string
the value if the validation was successful
valueObjects/string/NonEmptyString.ts:25
▸ Static Protected validateInterval(value, options): void
| Name | Type |
|---|---|
value |
string | number
|
options |
IntervalCreationOptions |
void
OptionalString.validateInterval
valueObjects/ValueObject.ts:86
▸ Static Protected validateList<Primitive>(list, options?): list is Primitive[]
| Name |
|---|
Primitive |
| Name | Type |
|---|---|
list |
undefined | Primitive[] |
options? |
CreationOptions & ListCreationOptions
|
list is Primitive[]
valueObjects/ValueObject.ts:101
▸ Static Private validateNonEmptyString(value, options): void
| Name | Type | Description |
|---|---|---|
value |
string |
to be validated as a valid string that is not the empty string ("") |
options |
undefined | NonEmptyStringOptions
|
constraints the value has to fulfill |
void
valueObjects/string/NonEmptyString.ts:43
▸ Static Private validateRange(value, options): void
| Name | Type | Description |
|---|---|---|
value |
string |
to be validated to match a given range (enum / string[]) |
options |
NonEmptyStringOptions |
constraints the value has to fulfill |
void
valueObjects/string/NonEmptyString.ts:61
▸ Static Protected validateRegex(value, options): void
| Name | Type | Description |
|---|---|---|
value |
string |
to be validated to match the given regular expression |
options |
OptionalStringOptions |
constraints the value has to fulfill |
void
valueObjects/string/OptionalString.ts:39
▸ Static Protected validateString(value, options?): void
| Name | Type | Description |
|---|---|---|
value |
string |
to be validated as a valid string |
options? |
OptionalStringOptions |
constraints the value has to fulfill |
void