MCPcopy
hub / github.com/louislam/dockge / validate

Method validate

backend/stack.ts:114–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112 }
113
114 validate() {
115 // Check name, allows [a-z][0-9] _ - only
116 if (!this.name.match(/^[a-z0-9_-]+$/)) {
117 throw new ValidationError("Stack name can only contain [a-z][0-9] _ - only");
118 }
119
120 // Check YAML format
121 yaml.parse(this.composeYAML);
122
123 let lines = this.composeENV.split("\n");
124
125 // Check if the .env is able to pass docker-compose
126 // Prevent "setenv: The parameter is incorrect"
127 // It only happens when there is one line and it doesn't contain "="
128 if (lines.length === 1 && !lines[0].includes("=") && lines[0].length > 0) {
129 throw new ValidationError("Invalid .env format");
130 }
131 }
132
133 get composeYAML() : string {
134 if (this._composeYAML === undefined) {

Callers 1

saveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected