(check, message)
| 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)) { |
nothing calls this directly
no test coverage detected