18 lines
368 B
JavaScript
18 lines
368 B
JavaScript
import { Field } from "./Field.js";
|
|
import { ValidationError } from "../ValidationError.js";
|
|
|
|
export class DomainField extends Field {
|
|
constructor(key, separator) {
|
|
super(key);
|
|
this.separator = separator;
|
|
}
|
|
|
|
validate(value) {
|
|
if (!value.match(/\w+(\.\w+)+/)) {
|
|
throw new ValidationError(`Field ${this.key} is not a valid domain`);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|