thrownewsequelizeErrors.ValidationError(util.format('%j is not a valid range',value));
}
if(value.length!==2){
thrownewsequelizeErrors.ValidationError('A range must be an array with two elements');
}
returntrue;
};
/**
/**
* A column storing a unique univeral identifier. Use with `UUIDV1` or `UUIDV4` for default values.
* A column storing a unique univeral identifier. Use with `UUIDV1` or `UUIDV4` for default values.
...
@@ -486,6 +582,13 @@ var UUID = function() {
...
@@ -486,6 +582,13 @@ var UUID = function() {
util.inherits(UUID,ABSTRACT);
util.inherits(UUID,ABSTRACT);
UUID.prototype.key=UUID.key='UUID';
UUID.prototype.key=UUID.key='UUID';
UUID.prototype.validate=function(value){
if(!Validator.isUUID(value)){
thrownewsequelizeErrors.ValidationError(util.format('%j is not a valid uuid',value));
}
returntrue;
};
/**
/**
* A default unique universal identifier generated following the UUID v1 standard
* A default unique universal identifier generated following the UUID v1 standard
...
@@ -499,6 +602,13 @@ var UUIDV1 = function() {
...
@@ -499,6 +602,13 @@ var UUIDV1 = function() {
util.inherits(UUIDV1,ABSTRACT);
util.inherits(UUIDV1,ABSTRACT);
UUIDV1.prototype.key=UUIDV1.key='UUIDV1';
UUIDV1.prototype.key=UUIDV1.key='UUIDV1';
UUIDV1.prototype.validate=function(value){
if(!Validator.isUUID(value)){
thrownewsequelizeErrors.ValidationError(util.format('%j is not a valid uuid',value));
}
returntrue;
};
/**
/**
* A default unique universal identifier generated following the UUID v2 standard
* A default unique universal identifier generated following the UUID v2 standard
...
@@ -512,6 +622,13 @@ var UUIDV4 = function() {
...
@@ -512,6 +622,13 @@ var UUIDV4 = function() {
util.inherits(UUIDV4,ABSTRACT);
util.inherits(UUIDV4,ABSTRACT);
UUIDV4.prototype.key=UUIDV4.key='UUIDV4';
UUIDV4.prototype.key=UUIDV4.key='UUIDV4';
UUIDV4.prototype.validate=function(value){
if(!Validator.isUUID(value,4)){
thrownewsequelizeErrors.ValidationError(util.format('%j is not a valid uuidv4',value));
}
returntrue;
};
/**
/**
* A virtual value that is not stored in the DB. This could for example be useful if you want to provide a default value in your model that is returned to the user but not stored in the DB.
* A virtual value that is not stored in the DB. This could for example be useful if you want to provide a default value in your model that is returned to the user but not stored in the DB.
...
@@ -565,6 +682,13 @@ var ENUM = function(value) {
...
@@ -565,6 +682,13 @@ var ENUM = function(value) {
util.inherits(ENUM,ABSTRACT);
util.inherits(ENUM,ABSTRACT);
ENUM.prototype.key=ENUM.key='ENUM';
ENUM.prototype.key=ENUM.key='ENUM';
ENUM.prototype.validate=function(value){
if(!_.contains(this.values,value)){
thrownewsequelizeErrors.ValidationError(util.format('%j is not a valid choice in %j',value,this.values));
}
returntrue;
};
/**
/**
* An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres.
* An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres.