MCPcopy
hub / github.com/di-sukharev/opencommit / refine

Method refine

out/cli.cjs:29693–29726  ·  view source on GitHub ↗
(check, message)

Source from the content-addressed store, hash-verified

29691 return handleResult(ctx, result);
29692 }
29693 refine(check, message) {
29694 const getIssueProperties = (val) => {
29695 if (typeof message === "string" || typeof message === "undefined") {
29696 return { message };
29697 } else if (typeof message === "function") {
29698 return message(val);
29699 } else {
29700 return message;
29701 }
29702 };
29703 return this._refinement((val, ctx) => {
29704 const result = check(val);
29705 const setError = () => ctx.addIssue({
29706 code: ZodError_1.ZodIssueCode.custom,
29707 ...getIssueProperties(val)
29708 });
29709 if (typeof Promise !== "undefined" && result instanceof Promise) {
29710 return result.then((data) => {
29711 if (!data) {
29712 setError();
29713 return false;
29714 } else {
29715 return true;
29716 }
29717 });
29718 }
29719 if (!result) {
29720 setError();
29721 return false;
29722 } else {
29723 return true;
29724 }
29725 });
29726 }
29727 refinement(check, refinementData) {
29728 return this._refinement((val, ctx) => {
29729 if (!check(val)) {

Callers

nothing calls this directly

Calls 2

_refinementMethod · 0.80
thenMethod · 0.80

Tested by

no test coverage detected