MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / _parse

Method _parse

out/cli.cjs:29870–30140  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

29868 }
29869 var ZodString = class _ZodString extends ZodType {
29870 _parse(input) {
29871 if (this._def.coerce) {
29872 input.data = String(input.data);
29873 }
29874 const parsedType = this._getType(input);
29875 if (parsedType !== util_1.ZodParsedType.string) {
29876 const ctx2 = this._getOrReturnCtx(input);
29877 (0, parseUtil_1.addIssueToContext)(ctx2, {
29878 code: ZodError_1.ZodIssueCode.invalid_type,
29879 expected: util_1.ZodParsedType.string,
29880 received: ctx2.parsedType
29881 });
29882 return parseUtil_1.INVALID;
29883 }
29884 const status = new parseUtil_1.ParseStatus();
29885 let ctx = void 0;
29886 for (const check of this._def.checks) {
29887 if (check.kind === "min") {
29888 if (input.data.length < check.value) {
29889 ctx = this._getOrReturnCtx(input, ctx);
29890 (0, parseUtil_1.addIssueToContext)(ctx, {
29891 code: ZodError_1.ZodIssueCode.too_small,
29892 minimum: check.value,
29893 type: "string",
29894 inclusive: true,
29895 exact: false,
29896 message: check.message
29897 });
29898 status.dirty();
29899 }
29900 } else if (check.kind === "max") {
29901 if (input.data.length > check.value) {
29902 ctx = this._getOrReturnCtx(input, ctx);
29903 (0, parseUtil_1.addIssueToContext)(ctx, {
29904 code: ZodError_1.ZodIssueCode.too_big,
29905 maximum: check.value,
29906 type: "string",
29907 inclusive: true,
29908 exact: false,
29909 message: check.message
29910 });
29911 status.dirty();
29912 }
29913 } else if (check.kind === "length") {
29914 const tooBig = input.data.length > check.value;
29915 const tooSmall = input.data.length < check.value;
29916 if (tooBig || tooSmall) {
29917 ctx = this._getOrReturnCtx(input, ctx);
29918 if (tooBig) {
29919 (0, parseUtil_1.addIssueToContext)(ctx, {
29920 code: ZodError_1.ZodIssueCode.too_big,
29921 maximum: check.value,
29922 type: "string",
29923 inclusive: true,
29924 exact: true,
29925 message: check.message
29926 });
29927 } else if (tooSmall) {

Callers

nothing calls this directly

Calls 13

datetimeRegexFunction · 0.85
timeRegexFunction · 0.85
isValidIPFunction · 0.85
_getTypeMethod · 0.80
_getOrReturnCtxMethod · 0.80
dirtyMethod · 0.80
testMethod · 0.80
trimMethod · 0.80
includesMethod · 0.80
toLowerCaseMethod · 0.80
toUpperCaseMethod · 0.80
startsWithMethod · 0.80

Tested by

no test coverage detected