Skip to content

Commit c9276a6

Browse files
committed
ApiKey entity
1 parent 85d817c commit c9276a6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/entities/Apikey.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11

22
import { Entity } from '../interfaces/Entity'
33

4-
export class ApiKey implements Entity {
4+
export class ApiKey implements Entity {
55
private apiKey
6+
private keyLength: number = 33
67
constructor(apiKey: string) {
78
this.apiKey = apiKey
89
}
910

1011
validate(): void {
11-
12+
if (!this.valid()) {
13+
throw new Error('invalid')
14+
}
1215
}
1316

1417
valid(): boolean {
15-
return this.apiKey.length !== 33
18+
return this.apiKey.length !== this.keyLength
1619
}
1720
}

0 commit comments

Comments
 (0)