Skip to content

Commit 8226905

Browse files
requested changes 3
1 parent 4492a3e commit 8226905

File tree

7 files changed

+14
-44
lines changed

7 files changed

+14
-44
lines changed

docs/schematypes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,12 @@ call it and assign the returned value to the path.
680680
The values `null` and `undefined` are not cast.
681681

682682
The following inputs will result will all result in a [CastError](validation.html#cast-errors) once validated, meaning that it will not throw on initialization, only when validated:
683-
- NaN
684-
- strings that cast to NaN
685-
- objects that don't have a `valueOf()` function
686-
- a decimal that must be rounded to be an integer
687-
- an input that represents a value beyond the bounds of an 32-bit integer
688683

684+
* NaN
685+
* strings that cast to NaN
686+
* objects that don't have a `valueOf()` function
687+
* a decimal that must be rounded to be an integer
688+
* an input that represents a value outside the bounds of an 32-bit integer
689689

690690
## Getters {#getters}
691691

lib/cast/int32.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const BSON = require('bson');
99
*
1010
* @param {Any} value
1111
* @return {Number}
12-
* @throws {Error} if `value` does not represent an integer, or is beyond the bounds of an 32-bit integer.
12+
* @throws {Error} if `value` does not represent an integer, or is outside the bounds of an 32-bit integer.
1313
* @api private
1414
*/
1515

lib/types/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ exports.Embedded = require('./arraySubdocument');
1414
exports.DocumentArray = require('./documentArray');
1515
exports.Decimal128 = require('./decimal128');
1616
exports.ObjectId = require('./objectid');
17-
exports.Int32 = require('./int32');
1817

1918
exports.Map = require('./map');
2019

lib/types/int32.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/int32.test.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Int32', function() {
2727
});
2828

2929
describe('supports the required property', function() {
30-
it('when value is null', async function() {
30+
it('when vaglue is null', async function() {
3131
const schema = new Schema({
3232
int32: {
3333
type: Schema.Types.Int32,
@@ -182,18 +182,6 @@ describe('Int32', function() {
182182
assert.strictEqual(doc.myInt, -997);
183183
});
184184

185-
it('casts from Mongoose Schema.Types.Int32', function() {
186-
const schema = new Schema({
187-
myInt: Schema.Types.Int32
188-
});
189-
const Test = mongoose.model('Test', schema);
190-
191-
const doc = new Test({
192-
myInt: new mongoose.Types.Int32(53)
193-
});
194-
assert.strictEqual(doc.myInt, 53);
195-
});
196-
197185
it('casts from BSON.Long provided its value is within bounds of Int32', function() {
198186
const schema = new Schema({
199187
myInt: Schema.Types.Int32
@@ -393,7 +381,7 @@ describe('Int32', function() {
393381
mongoose.Schema.Types.Int32.cast(defaultCast);
394382
});
395383

396-
it('supports cast disabled', () => {
384+
it('supports cast disabled', async() => {
397385
mongoose.Schema.Types.Int32.cast(false);
398386
const schema = new Schema({
399387
myInt1: {
@@ -405,11 +393,15 @@ describe('Int32', function() {
405393
});
406394
const Test = mongoose.model('Test', schema);
407395
const doc = new Test({
408-
myInt: '52',
396+
myInt1: '52',
409397
myInt2: 52
410398
});
411399
assert.strictEqual(doc.myInt1, undefined);
412400
assert.strictEqual(doc.myInt2, 52);
401+
402+
const err = await doc.validate().catch(e => e);
403+
assert.ok(err);
404+
assert.ok(err.errors['myInt1']);
413405
});
414406

415407
it('supports custom cast', () => {

test/types/schema.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,6 @@ export function autoTypedSchema() {
425425
decimal1?: Types.Decimal128 | null;
426426
decimal2?: Types.Decimal128 | null;
427427
decimal3?: Types.Decimal128 | null;
428-
int32_1?: Types.Int32 | null;
429-
int32_2?: Types.Int32 | null;
430-
int32_3?: Types.Int32 | null;
431428
};
432429

433430
const TestSchema = new Schema({
@@ -474,10 +471,7 @@ export function autoTypedSchema() {
474471
array8: { type: [String], default: () => undefined },
475472
decimal1: Schema.Types.Decimal128,
476473
decimal2: 'Decimal128',
477-
decimal3: 'decimal128',
478-
int32_1: Schema.Types.Int32,
479-
int32_2: 'Int32',
480-
int32_3: 'int32'
474+
decimal3: 'decimal128'
481475
});
482476

483477
type InferredTestSchemaType = InferSchemaType<typeof TestSchema>;

types/types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ declare module 'mongoose' {
6060

6161
class Decimal128 extends mongodb.Decimal128 { }
6262

63-
class Int32 extends mongodb.Int32 { }
64-
6563
class DocumentArray<T> extends Types.Array<T extends Types.Subdocument ? T : Types.Subdocument<InferId<T>, any, T> & T> {
6664
/** DocumentArray constructor */
6765
constructor(values: AnyObject[]);

0 commit comments

Comments
 (0)