import { Field } from "./Field.js"; import { ValidationError } from "../ValidationError.js"; export class DmarcUriListField extends Field { constructor(key) { super(key); } validate(value) { const uris = value.split(","); for (let uri of uris) { uri = uri.replace(/!\d+[kmgt]$/); try { new URL(uri); } catch(e) { throw new ValidationError(`Invalid URI for field "${this.key}": ${uri}`); } } return true; } getInputHtml() { return ``; } getInputValue() { if (!document.getElementById(this.id).value) { return null; } return "mailto:" + document.getElementById(this.id).value; } }