25 lines
830 B
JavaScript
25 lines
830 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.Url = void 0;
|
|
const ValueObject_1 = require("../../../../shared/domain/ValueObject");
|
|
const Result_1 = require("../../../../shared/domain/Result");
|
|
class Url extends ValueObject_1.ValueObject {
|
|
constructor(props) {
|
|
super(props);
|
|
}
|
|
static create(raw) {
|
|
if (!raw || raw.trim().length === 0) {
|
|
return (0, Result_1.Err)('URL must not be empty');
|
|
}
|
|
const trimmed = raw.trim();
|
|
if (!trimmed.startsWith('http://') && !trimmed.startsWith('https://')) {
|
|
return (0, Result_1.Err)('URL must start with http:// or https://');
|
|
}
|
|
return (0, Result_1.Ok)(new Url({ value: trimmed }));
|
|
}
|
|
toString() {
|
|
return this.props.value;
|
|
}
|
|
}
|
|
exports.Url = Url;
|