-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathinvalid-input.ts
74 lines (53 loc) · 1.91 KB
/
invalid-input.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { RedisOmError } from './redis-om-error'
import { Field } from '../schema'
export class InvalidInput extends RedisOmError {}
export class NullJsonInput extends InvalidInput {
#field
constructor(field: Field) {
const message = `Null or undefined found in field '${field.name}' of type '${field.type}' in JSON at '${field.jsonPath}'.`
super(message)
this.#field = field
}
get fieldName() { return this.#field.name }
get fieldType() { return this.#field.type }
get jsonPath() { return this.#field.jsonPath }
}
export class InvalidJsonInput extends InvalidInput {
#field
constructor(field: Field) {
const message = `Unexpected value for field '${field.name}' of type '${field.type}' in JSON at '${field.jsonPath}'.`
super(message)
this.#field = field
}
get fieldName() { return this.#field.name }
get fieldType() { return this.#field.type }
get jsonPath() { return this.#field.jsonPath }
}
export class InvalidHashInput extends InvalidInput {
#field
constructor(field: Field) {
const message = `Unexpected value for field '${field.name}' of type '${field.type}' in Hash.`
super(message)
this.#field = field
}
get fieldName() { return this.#field.name }
get fieldType() { return this.#field.type }
}
export class NestedHashInput extends InvalidInput {
#property
constructor(property: string) {
const message = `Unexpected object in Hash at property '${property}'. You can not store a nested object in a Redis Hash.`
super(message)
this.#property = property
}
get field() { return this.#property }
}
export class ArrayHashInput extends InvalidInput {
#property
constructor(property: string) {
const message = `Unexpected array in Hash at property '${property}'. You can not store an array in a Redis Hash without defining it in the Schema.`
super(message)
this.#property = property
}
get field() { return this.#property }
}