email-dns-tools/assets/scripts/spf/Term.js

42 lines
623 B
JavaScript

import { ValueRequirement } from "./ValueRequirement.js";
export class Term {
separator = null;
isRequired = false;
position = null;
allowMultiple = false;
valueRequirement = ValueRequirement.REQUIRED;
validationFunction = null;
constructor(key) {
this.key = key;
}
// Builder methods
required() {
this.isRequired = true;
return this;
}
pos(i) {
this.position = i;
return this;
}
multiple() {
this.allowMultiple = true;
return this;
}
value(requirement) {
this.valueRequirement = requirement;
return this;
}
validate(func) {
this.validationFunction = func;
return this;
}
}