import { Field } from "./Field.js"; import { ValidationError } from "../ValidationError.js"; export class EnumField extends Field { separator = "="; constructor(key, values) { super(key); this.values = values; this.optionLabels = values; } validate(value) { if (this.values.includes(value)) return true; throw new ValidationError(`Invalid value for field "${this.key}" - must be one of: ${this.values.join(", ")}`); } getInputHtml() { return ``; } getInputValue() { return document.getElementById(this.id).value; } options(options) { this.optionLabels = options; return this; } }