soda-angular
Version:
Socrata SODA client for Angular
16 lines (15 loc) • 426 B
JavaScript
export class SodaResourceId {
constructor(id) {
this.id = id;
const validationRegEx = new RegExp(/^[a-z0-9]{4}-[a-z0-9]{4}$/);
if (!this.id) {
throw new Error("Id must be provided");
}
if (!validationRegEx.test(this.id)) {
throw new Error("Id must be in the format xxxx-xxxx");
}
}
toString() {
return this.id;
}
}