aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/models/internal/FormError.ts
blob: f6d8978d33f13a450958a6843d63cf2589f7f3b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { KnownProblem } from "./KnownProblem";

export class FormError {
    title: string;
    subtitle: string;
    constructor(title: string = "", subtitle: string = "") {
        this.title = title;
        this.title = subtitle;
    }

    set(title: string = "", subtitle: string = "") {
        this.title = title;
        this.subtitle = subtitle;
    }

    set_from_known_problem(knownProblem: KnownProblem) {
        this.title = knownProblem.title ?? "";
        this.subtitle = knownProblem.subtitle ?? "";
    }

    has_error() {
        return this.title?.length > 0 || this.subtitle?.length > 0;
    }
}