Skip to content

Commit

Permalink
remove bignInt possiblity in input for isValidInteger and remove stri…
Browse files Browse the repository at this point in the history
…ct mode
  • Loading branch information
technophile-04 committed Sep 23, 2024
1 parent 75b2789 commit a15ed62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const IntegerInput = ({
}, [onChange, value]);

useEffect(() => {
if (isValidInteger(variant, value, false)) {
if (isValidInteger(variant, value)) {
setInputError(false);
} else {
setInputError(true);
Expand Down
5 changes: 1 addition & 4 deletions packages/nextjs/components/scaffold-eth/Input/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export enum IntegerVariant {
export const SIGNED_NUMBER_REGEX = /^-?\d+\.?\d*$/;
export const UNSIGNED_NUMBER_REGEX = /^\.?\d+\.?\d*$/;

export const isValidInteger = (dataType: IntegerVariant, value: bigint | string, strict = true) => {
export const isValidInteger = (dataType: IntegerVariant, value: string) => {
const isSigned = dataType.startsWith("i");
const bitcount = Number(dataType.substring(isSigned ? 3 : 4));

Expand All @@ -85,9 +85,6 @@ export const isValidInteger = (dataType: IntegerVariant, value: bigint | string,
valueAsBigInt = BigInt(value);
} catch (e) {}
if (typeof valueAsBigInt !== "bigint") {
if (strict) {
return false;
}
if (!value || typeof value !== "string") {
return true;
}
Expand Down

0 comments on commit a15ed62

Please sign in to comment.