Repository: json-schema-faker/json-schema-faker
Pull request #835 (2024-12-31 12:41:42)

Fix large minimum generation without specified maximum
There was an issue with timestamp integer value which is bigger than [hardcoded min value](https://github.com/json-schema-faker/json-schema-faker/blob/master/src/lib/core/constants.mjs#L8):
![Screenshot 2024-12-31 at 12 29 20](https://github.com/user-attachments/assets/55166ef8-7830-438d-b1e3-7bb09598af1e)

Please fill free to modify or notify if anything :) thanks


Patch:
diff --git a/README.md b/README.md
index 252ea9b..c4b6a13 100644
--- a/README.md
+++ b/README.md
@@ -2,15 +2,13 @@
 
 [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8MXLRJ7QQXGYY)
 [![OpenCollective](https://badgen.net/opencollective/backers/json-schema-faker)](https://opencollective.com/json-schema-faker)
-[![Build status](https://github.com/json-schema-faker/json-schema-faker/workflows/ci/badge.svg)](https://github.com/json-schema-faker/json-schema-faker/actions)
+[![Build status](https://github.com/json-schema-faker/json-schema-faker/actions/workflows/testing.yml/badge.svg)](https://github.com/json-schema-faker/json-schema-faker/actions)
 [![NPM version](https://badge.fury.io/js/json-schema-faker.svg)](http://badge.fury.io/js/json-schema-faker)
 [![Coverage Status](https://codecov.io/github/json-schema-faker/json-schema-faker/coverage.svg?branch=master)](https://codecov.io/github/json-schema-faker/json-schema-faker?branch=master)
 
 [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/json-schema-faker/Lobby)
-[![Dependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker)
-[![devDependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/dev-status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker#info=devDependencies)
 
-[![Inline docs](http://inch-ci.org/github/json-schema-faker/json-schema-faker.svg?branch=master)](http://inch-ci.org/github/json-schema-faker/json-schema-faker)
+[![Inline docs](https://inch-ci.org/github/json-schema-faker/json-schema-faker.svg?branch=master)](https://inch-ci.org/github/json-schema-faker/json-schema-faker)
 [![Typedoc](https://img.shields.io/badge/typedoc-provided-blue.svg)](http://json-schema-faker.github.io/json-schema-faker/)
 [![Known Vulnerabilities](https://snyk.io/test/github/json-schema-faker/json-schema-faker/badge.svg)](https://snyk.io/test/github/json-schema-faker/json-schema-faker)
 
diff --git a/package.json b/package.json
index 9ed6917..639ebc1 100644
--- a/package.json
+++ b/package.json
@@ -149,4 +149,4 @@
     "yrv": "^0.0.47",
     "z-schema": "^5.0.4"
   }
-}
+}
\ No newline at end of file
diff --git a/src/lib/types/number.mjs b/src/lib/types/number.mjs
index 4ee101e..cca0881 100644
--- a/src/lib/types/number.mjs
+++ b/src/lib/types/number.mjs
@@ -2,8 +2,16 @@ import random from '../core/random.mjs';
 import env from '../core/constants.mjs';
 
 function numberType(value) {
-  let min = (typeof value.minimum === 'undefined' || value.minimum === -Number.MAX_VALUE) ? env.MIN_INTEGER : value.minimum;
-  let max = (typeof value.maximum === 'undefined' || value.maximum === Number.MAX_VALUE) ? env.MAX_INTEGER : value.maximum;
+  let min = (typeof value.minimum === 'undefined' || value.minimum === -Number.MAX_VALUE)
+    ? env.MIN_INTEGER
+    : value.minimum;
+  let max = (typeof value.maximum === 'undefined' || value.maximum === Number.MAX_VALUE)
+    ? env.MAX_INTEGER
+    : value.maximum;
+
+  if (min > max) {
+    max = Number.MAX_SAFE_INTEGER;
+  }
 
   const multipleOf = value.multipleOf;
   const decimals = multipleOf && String(multipleOf).match(/e-(\d)|\.(\d+)$/);


Test patch:
diff --git a/tests/unit/generators/number.spec.mjs b/tests/unit/generators/number.spec.mjs
index 3e2fe14..b7da9a7 100644
--- a/tests/unit/generators/number.spec.mjs
+++ b/tests/unit/generators/number.spec.mjs
@@ -14,6 +14,13 @@ describe('Number Generator', () => {
     expect(n).not.to.eql(m);
   });
 
+  it('should return number with large minimum without specified maximum', () => {
+    const n = numberType({ minimum: 1682899200000 });
+
+    expect(n).to.be.a('number');
+    expect(n).to.be.at.least(1682899200000);
+  });
+
   it('should handle multipleOf on integers', () => {
     expect(isMultipleOf({ multipleOf: 1 })).to.be.true;
     expect(isMultipleOf({ multipleOf: 1, maximum: 1e+31 })).to.be.true;