diff --git a/src/parsing/numbers/IntParser.ts b/src/parsing/numbers/IntParser.ts index 03bd7c3..904b5a7 100644 --- a/src/parsing/numbers/IntParser.ts +++ b/src/parsing/numbers/IntParser.ts @@ -30,7 +30,7 @@ export class IntParser implements IInt.Parser { return new IntParser(this.parent, this.parseCurrent, this.radix, !this.negate); } - readonly withRadix = (value?: number) => new IntParser(this.parent, asCurrent(provideParseInt(value), this.negate), this.radix, this.negate); + readonly withRadix = (value?: number) => new IntParser(this.parent, asCurrent(provideParseInt(value), this.negate), value, this.negate); readonly equals = (value: NumberParsableTypes) => new IntParser(this, asCurrent(provideEquals(parseInt(value, this.radix)), this.negate), this.radix); readonly anyOf = (values: NumberParsableTypes[] | NumberEnumMap) => new IntParser(this, asCurrent(provideAnyOf(ensureNumberArray(values)), this.negate), this.radix); diff --git a/src/parsing/numbers/numbers-int.spec.ts b/src/parsing/numbers/numbers-int.spec.ts index f7c68c2..b64462e 100644 --- a/src/parsing/numbers/numbers-int.spec.ts +++ b/src/parsing/numbers/numbers-int.spec.ts @@ -44,6 +44,14 @@ describe('numbers-int', () => { expect(result.value).toBe(null); }); + it('success binary', () => { + const value = '101'; + const result = schema.withRadix(2).parse(value); + + expect(result.errors).toEqual(ParseErrors.empty); + expect(result.value).toBe(5); + }); + it('failure not int (float)', () => { const value = 1.2; const result = schema.parse(value);