-
Notifications
You must be signed in to change notification settings - Fork 0
/
attachment.model.ts
40 lines (36 loc) · 1004 Bytes
/
attachment.model.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
import { Resource } from './resource.model';
/**
* An attachment to attach to a resource.
*/
export class Attachment extends Resource {
/**
* The id of the attachment.
*/
attachmentId: string;
/**
* The name of the resource. This can be changed when attaching to the resource.
*/
name: string;
/**
* The format of the resource. (e.g. 'jpg', 'pdf').
*/
format: string;
load(x: any): void {
super.load(x);
this.attachmentId = this.clean(x.attachmentId, String);
this.name = this.clean(x.name, String);
this.format = this.clean(x.format, String);
}
safeLoad(newData: any, safeData: any): void {
super.safeLoad(newData, safeData);
this.attachmentId = safeData.attachmentId;
this.format = safeData.format;
}
validate(): string[] {
const e = super.validate();
if (this.iE(this.attachmentId)) e.push('attachmentId');
if (this.iE(this.name)) e.push('name');
if (this.iE(this.format)) e.push('format');
return e;
}
}