Comparing version 0.1.2 to 0.2.0
@@ -24,5 +24,6 @@ 'use strict'; | ||
this.transforms = [] | ||
this._type = 'mixed' | ||
_.extend(this, props) | ||
this._type = 'mixed' | ||
} | ||
@@ -202,19 +203,16 @@ | ||
SchemaType.create = function(spec){ | ||
var Klass = this | ||
initProps = spec | ||
return new this(); | ||
return new Klass; | ||
} | ||
SchemaType.extend = function(spec){ | ||
var base = this | ||
, proto = Object.create(base.prototype) | ||
, child; | ||
var proto = Object.create(this.prototype) | ||
, child = spec.constructor; | ||
_.extend(child, this) | ||
_.extend(proto, spec) | ||
child = proto && _.has(proto, 'constructor') | ||
? proto.constructor | ||
: function DefaultConstructor(){ return base.apply(this, arguments) } | ||
child.prototype = proto | ||
child.prototype.constructor = child | ||
_.extend(child, base); | ||
return child | ||
@@ -221,0 +219,0 @@ } |
@@ -14,8 +14,7 @@ 'use strict'; | ||
constructor: function(){ | ||
if ( !(this instanceof _String)) return new _String() | ||
if ( !(this instanceof _String)) | ||
return new _String() | ||
SchemaObject.call(this) | ||
this._type = 'string' | ||
if ( !_.has(this, '_default')) this._default = '' | ||
if ( !_.has(this, '_nullable')) this._nullable = true | ||
}, | ||
@@ -22,0 +21,0 @@ |
{ | ||
"name": "yup", | ||
"version": "0.1.2", | ||
"description": "client model and persistence mechanism", | ||
"version": "0.2.0", | ||
"description": "Dead simple Object schema validation", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -102,3 +102,3 @@ 'use strict'; | ||
it.only('should call shape with constructed with an arg', function(){ | ||
it('should call shape with constructed with an arg', function(){ | ||
var inst = object({ | ||
@@ -105,0 +105,0 @@ prop: mixed(), |
@@ -28,3 +28,3 @@ 'use strict'; | ||
chai.expect(inst.cast()).to.equal('') | ||
chai.expect(inst.cast()).to.equal(undefined) | ||
@@ -39,3 +39,2 @@ inst.trim().cast(' 3 ').should.equal('3') | ||
inst.default().should.equal('') | ||
inst.default('my_value').required().default().should.equal('my_value') | ||
@@ -49,3 +48,3 @@ }) | ||
inst.isType(false).should.equal(false) | ||
inst.isType(null).should.equal(true) | ||
inst.isType(null).should.equal(false) | ||
inst.nullable(false).isType(null).should.equal(false) | ||
@@ -57,4 +56,4 @@ }) | ||
string().strict().isValid(null).should.equal(true) | ||
string().strict().nullable(false).isValid(null).should.equal(false) | ||
string().strict().isValid(null).should.equal(false) | ||
string().strict().nullable(true).isValid(null).should.equal(true) | ||
@@ -61,0 +60,0 @@ inst.isValid('hello').should.equal(true) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55621
1195