@codeparticle/formal
Version:
A <2kb library for validating data of any kind
38 lines (36 loc) • 728 B
JavaScript
import {
checkIsValidationM
} from "./chunk-BWJJJL7W.mjs";
// src/success.ts
var Success = class {
constructor(value) {
this.isSuccess = true;
this.errors = [];
this.value = null;
this.value = value;
this.errors = [];
}
static of(value) {
return new Success(value);
}
map(fn) {
return new Success(fn(this.value));
}
chain(validationFn) {
try {
const result = validationFn(this.value);
checkIsValidationM(result);
return result;
} catch (error) {
console.error(error.message);
console.error(error.stack);
}
}
fold({ onSuccess }) {
return onSuccess(this.value);
}
};
export {
Success
};
//# sourceMappingURL=chunk-ULL3TXJG.mjs.map