不要怂,就是干,撸起袖子干!

Commit e2e77ae0 by Sushant Committed by Jan Aagaard Meier

(clean up) dont global patch validator (#6201)

1 parent 0e0ffd70
...@@ -17,12 +17,15 @@ ...@@ -17,12 +17,15 @@
- [ADDED] before/after Upsert hook [#3965](https://github.com/sequelize/sequelize/issues/3965) - [ADDED] before/after Upsert hook [#3965](https://github.com/sequelize/sequelize/issues/3965)
- [FIXED] Modifying `options` in `beforeFind` throws error [#5675](https://github.com/sequelize/sequelize/issues/5675) - [FIXED] Modifying `options` in `beforeFind` throws error [#5675](https://github.com/sequelize/sequelize/issues/5675)
- [REMOVED] `classMethods` and `instanceMethods` [#5869](https://github.com/sequelize/sequelize/issues/5869#issuecomment-221773485) - [REMOVED] `classMethods` and `instanceMethods` [#5869](https://github.com/sequelize/sequelize/issues/5869#issuecomment-221773485)
- [CHANGED] `Sequelize.Validator` is now an independent copy of `validator` library
- [FIXED] Don't patch `validator` library globally [#6196](https://github.com/sequelize/sequelize/issues/6196)
## BC breaks: ## BC breaks:
- Range type bounds now default to [postgres default](https://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-CONSTRUCT) `[)` (inclusive, exclusive), previously was `()` (exclusive, exclusive) - Range type bounds now default to [postgres default](https://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-CONSTRUCT) `[)` (inclusive, exclusive), previously was `()` (exclusive, exclusive)
- Only `belongsTo` uses `as` to construct foreign key - revert of [#5957](https://github.com/sequelize/sequelize/pull/5957) introduced in 4.0.0-0 - Only `belongsTo` uses `as` to construct foreign key - revert of [#5957](https://github.com/sequelize/sequelize/pull/5957) introduced in 4.0.0-0
- Sequelize uses an independent copy of `bluebird` library. This means (1) promises returned from Sequelize methods are instances of `Sequelize.Promise` but not global `Bluebird` and (2) the CLS patch does not affect global `Bluebird`. - Sequelize uses an independent copy of `bluebird` library. This means (1) promises returned from Sequelize methods are instances of `Sequelize.Promise` but not global `Bluebird` and (2) the CLS patch does not affect global `Bluebird`.
- Dropped support for `classMethods` and `instanceMethods`. As Models are now ES6 classes `classMethods` can be directly assigned and `instanceMethods` should be added to `Model.prototype` - Dropped support for `classMethods` and `instanceMethods`. As Models are now ES6 classes `classMethods` can be directly assigned and `instanceMethods` should be added to `Model.prototype`
- `Sequelize.Validator` is now a cloned version of `validator`, It will not pollute global library methods.
# 4.0.0-0 # 4.0.0-0
- [FIXED] Pass ResourceLock instead of raw connection in MSSQL disconnect handling - [FIXED] Pass ResourceLock instead of raw connection in MSSQL disconnect handling
......
...@@ -7,7 +7,7 @@ const _ = require('lodash'); ...@@ -7,7 +7,7 @@ const _ = require('lodash');
const Wkt = require('terraformer-wkt-parser'); const Wkt = require('terraformer-wkt-parser');
const sequelizeErrors = require('./errors'); const sequelizeErrors = require('./errors');
const warnings = {}; const warnings = {};
const Validator = require('validator'); const Validator = require('./utils/validator-extras').validator;
const momentTz = require('moment-timezone'); const momentTz = require('moment-timezone');
const moment = require('moment'); const moment = require('moment');
......
...@@ -15,6 +15,7 @@ const sequelizeErrors = require('./errors'); ...@@ -15,6 +15,7 @@ const sequelizeErrors = require('./errors');
const Promise = require('./promise'); const Promise = require('./promise');
const Hooks = require('./hooks'); const Hooks = require('./hooks');
const Association = require('./associations/index'); const Association = require('./associations/index');
const Validator = require('./utils/validator-extras').validator;
const _ = require('lodash'); const _ = require('lodash');
/** /**
...@@ -1219,7 +1220,7 @@ Sequelize.prototype.QueryTypes = Sequelize.QueryTypes = QueryTypes; ...@@ -1219,7 +1220,7 @@ Sequelize.prototype.QueryTypes = Sequelize.QueryTypes = QueryTypes;
* @property Validator * @property Validator
* @see https://github.com/chriso/validator.js * @see https://github.com/chriso/validator.js
*/ */
Sequelize.prototype.Validator = Sequelize.Validator = require('validator'); Sequelize.prototype.Validator = Sequelize.Validator = Validator;
Sequelize.prototype.Model = Sequelize.Model = Model; Sequelize.prototype.Model = Sequelize.Model = Model;
......
'use strict'; 'use strict';
const validator = require('validator');
const _ = require('lodash'); const _ = require('lodash');
const validator = _.cloneDeep(require('validator'));
const extensions = { const extensions = {
extend(name, fn) { extend(name, fn) {
...@@ -38,7 +38,7 @@ const extensions = { ...@@ -38,7 +38,7 @@ const extensions = {
return !this.regex(str, pattern, modifiers); return !this.regex(str, pattern, modifiers);
}, },
isDecimal(str) { isDecimal(str) {
return str !== '' && str.match(/^(?:-?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/); return str !== '' && !!str.match(/^(?:-?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/);
}, },
min(str, val) { min(str, val) {
const number = parseFloat(str); const number = parseFloat(str);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!