18 lines
371 B
JavaScript
18 lines
371 B
JavaScript
import { Field } from "./Field.js";
|
|
import { ValidationError } from "../ValidationError.js";
|
|
|
|
export class ConstantField extends Field {
|
|
constructor(key, value) {
|
|
super(key);
|
|
this.value = value;
|
|
}
|
|
|
|
validate(value) {
|
|
if (this.value !== value) throw new ValidationError(`Field ${this.key} must be "${this.value}"`)
|
|
}
|
|
|
|
getInputValue() {
|
|
return this.value;
|
|
}
|
|
}
|