@umbraco/json-models-builders
Version:
Builders and models for Umbraco Sites
114 lines • 2.99 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MemberTypePropertyBuilder = void 0;
class MemberTypePropertyBuilder {
parentBuilder;
id;
containerId;
sortOrder;
alias;
name;
description;
dataTypeId;
variesByCulture;
variesBySegment;
mandatory;
mandatoryMessage;
regEx;
regExMessage;
labelOnTop;
constructor(parentBuilder) {
this.parentBuilder = parentBuilder;
}
withId(id) {
this.id = id;
return this;
}
withContainerId(containerId) {
this.containerId = containerId;
return this;
}
withSortOrder(sortOrder) {
this.sortOrder = sortOrder;
return this;
}
withAlias(alias) {
this.alias = alias;
return this;
}
withName(name) {
this.name = name;
return this;
}
withDescription(description) {
this.description = description;
return this;
}
withDataTypeId(dataTypeId) {
this.dataTypeId = dataTypeId;
return this;
}
withVariesByCulture(variesByCulture) {
this.variesByCulture = variesByCulture;
return this;
}
withVariesBySegment(variesBySegment) {
this.variesBySegment = variesBySegment;
return this;
}
withMandatory(mandatory) {
this.mandatory = mandatory;
return this;
}
withMandatoryMessage(mandatoryMessage) {
this.mandatoryMessage = mandatoryMessage;
return this;
}
withRegEx(regEx) {
this.regEx = regEx;
return this;
}
withRegExMessage(regExMessage) {
this.regExMessage = regExMessage;
return this;
}
withLabelOnTop(labelOnTop) {
this.labelOnTop = labelOnTop;
return this;
}
done() {
return this.parentBuilder;
}
build() {
if (!this.id) {
const crypto = require('crypto');
this.id = crypto.randomUUID();
}
return {
id: this.id,
container: {
id: this.containerId || null
},
sortOrder: this.sortOrder || 0,
alias: this.alias || "",
name: this.name || "",
description: this.description || "",
dataType: {
id: this.dataTypeId || null
},
variesByCulture: this.variesByCulture || false,
variesBySegment: this.variesBySegment || false,
validation: {
mandatory: this.mandatory || false,
mandatoryMessage: this.mandatoryMessage || "",
regEx: this.regEx || "",
regExMessage: this.regExMessage || ""
},
appearance: {
labelOnTop: this.labelOnTop || false
}
};
}
}
exports.MemberTypePropertyBuilder = MemberTypePropertyBuilder;
//# sourceMappingURL=memberTypePropertyBuilder.js.map