18 lines
422 B
JavaScript
18 lines
422 B
JavaScript
import { ValidationError } from "../ValidationError.js";
|
|
import { Mechanism } from "./Mechanism.js";
|
|
import { validateSpfDomain } from "./utils.js";
|
|
|
|
export class DomainMechanism extends Mechanism {
|
|
placeholder = "example.com";
|
|
|
|
constructor(key) {
|
|
super(key);
|
|
}
|
|
|
|
validate(value) {
|
|
if (!validateSpfDomain(value)) throw new ValidationError(`Value for "${this.key}" is not a valid domain name`);
|
|
|
|
return true;
|
|
}
|
|
}
|