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

Method _parse

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

Source from the content-addressed store, hash-verified

30384 this.step = this.multipleOf;
30385 }
30386 _parse(input) {
30387 if (this._def.coerce) {
30388 input.data = Number(input.data);
30389 }
30390 const parsedType = this._getType(input);
30391 if (parsedType !== util_1.ZodParsedType.number) {
30392 const ctx2 = this._getOrReturnCtx(input);
30393 (0, parseUtil_1.addIssueToContext)(ctx2, {
30394 code: ZodError_1.ZodIssueCode.invalid_type,
30395 expected: util_1.ZodParsedType.number,
30396 received: ctx2.parsedType
30397 });
30398 return parseUtil_1.INVALID;
30399 }
30400 let ctx = void 0;
30401 const status = new parseUtil_1.ParseStatus();
30402 for (const check of this._def.checks) {
30403 if (check.kind === "int") {
30404 if (!util_1.util.isInteger(input.data)) {
30405 ctx = this._getOrReturnCtx(input, ctx);
30406 (0, parseUtil_1.addIssueToContext)(ctx, {
30407 code: ZodError_1.ZodIssueCode.invalid_type,
30408 expected: "integer",
30409 received: "float",
30410 message: check.message
30411 });
30412 status.dirty();
30413 }
30414 } else if (check.kind === "min") {
30415 const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
30416 if (tooSmall) {
30417 ctx = this._getOrReturnCtx(input, ctx);
30418 (0, parseUtil_1.addIssueToContext)(ctx, {
30419 code: ZodError_1.ZodIssueCode.too_small,
30420 minimum: check.value,
30421 type: "number",
30422 inclusive: check.inclusive,
30423 exact: false,
30424 message: check.message
30425 });
30426 status.dirty();
30427 }
30428 } else if (check.kind === "max") {
30429 const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
30430 if (tooBig) {
30431 ctx = this._getOrReturnCtx(input, ctx);
30432 (0, parseUtil_1.addIssueToContext)(ctx, {
30433 code: ZodError_1.ZodIssueCode.too_big,
30434 maximum: check.value,
30435 type: "number",
30436 inclusive: check.inclusive,
30437 exact: false,
30438 message: check.message
30439 });
30440 status.dirty();
30441 }
30442 } else if (check.kind === "multipleOf") {
30443 if (floatSafeRemainder(input.data, check.value) !== 0) {

Callers

nothing calls this directly

Calls 5

floatSafeRemainderFunction · 0.85
_getTypeMethod · 0.80
_getOrReturnCtxMethod · 0.80
dirtyMethod · 0.80
isFiniteMethod · 0.80

Tested by

no test coverage detected