-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathinvalid-value.ts
49 lines (36 loc) · 1.37 KB
/
invalid-value.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
import { RedisOmError } from './redis-om-error'
import { Field } from '../schema'
export class InvalidValue extends RedisOmError {}
export class NullJsonValue extends InvalidValue {
#field
constructor(field: Field) {
const message = `Null or undefined found in field '${field.name}' of type '${field.type}' from JSON path '${field.jsonPath}' in Redis.`
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 InvalidJsonValue extends InvalidValue {
#field
constructor(field: Field) {
const message = `Unexpected value for field '${field.name}' of type '${field.type}' from JSON path '${field.jsonPath}' in Redis.`
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 InvalidHashValue extends InvalidValue {
#field
constructor(field: Field) {
const message = `Unexpected value for field '${field.name}' of type '${field.type}' from Hash field '${field.hashField}' read from Redis.`
super(message)
this.#field = field
}
get fieldName() { return this.#field.name }
get fieldType() { return this.#field.type }
get hashField() { return this.#field.hashField }
}