scotthovestadt / schema-object

Enforce schema on JavaScript objects, including type, transformation, and validation. Supports extends, sub-schemas, and arrays.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

issue with custom created data type

blnprasad opened this issue · comments

Hi,
Look like with recent changes usage of custorm created data type is broken. please check the same

Hi,

Can you give me some example code? All of the unit tests pass. I just double checked and the follow code tests fine:

var MyString = {type: String, minLength: 5, maxLength: 10};
var SO = new SchemaObject({
  customString: MyString,
});

var o = new SO();
o.customString = '1234';
should.not.exist(o.customString);
o.customString = '12345';
o.customString.should.equal('12345');

o.customString = '1234567890';
o.customString.should.equal('1234567890');

Hi,

can you please try below code(modified) and see?

var MyString = {type: String, minLength: 5, maxLength: 10};
var SO = new SchemaObject({
customString: MyString,

custromString1: MyString

});

var o = new SO();
o.customString = '1234';
should.not.exist(o.customString);
o.customString = '12345';

O.custromString1 = '6789'

o.customString.should.equal('12345');

o.customString = '1234567890';

o.customString1 = '1234';
o.customString.should.equal('1234567890');

Thanks & Regards,
BLN
On Wed, Oct 22, 2014 at 12:57 PM, scotthovestadt notifications@github.com
wrote:

Hi,

Can you give me some example code? All of the unit tests pass. I just
double checked and the follow code tests fine:

var MyString = {type: String, minLength: 5, maxLength: 10};
var SO = new SchemaObject({
customString: MyString,
});

var o = new SO();
o.customString = '1234';
should.not.exist(o.customString);
o.customString = '12345';
o.customString.should.equal('12345');

o.customString = '1234567890';
o.customString.should.equal('1234567890');


Reply to this email directly or view it on GitHub
#10 (comment)
.

Issue happens when we use custom data type multiple times in schema Object
as both uses same memory reference and last one that uses wins.

Regards,
BLN

On Wed, Oct 22, 2014 at 1:56 PM, bln prasad prasad.bln@gmail.com wrote:

Hi,

can you please try below code(modified) and see?

var MyString = {type: String, minLength: 5, maxLength: 10};
var SO = new SchemaObject({
customString: MyString,

custromString1: MyString

});

var o = new SO();
o.customString = '1234';
should.not.exist(o.customString);
o.customString = '12345';

O.custromString1 = '6789'

o.customString.should.equal('12345');

o.customString = '1234567890';

o.customString1 = '1234';
o.customString.should.equal('1234567890');

Thanks & Regards,
BLN

On Wed, Oct 22, 2014 at 12:57 PM, scotthovestadt <notifications@github.com

wrote:

Hi,

Can you give me some example code? All of the unit tests pass. I just
double checked and the follow code tests fine:

var MyString = {type: String, minLength: 5, maxLength: 10};
var SO = new SchemaObject({
customString: MyString,
});

var o = new SO();
o.customString = '1234';
should.not.exist(o.customString);
o.customString = '12345';
o.customString.should.equal('12345');

o.customString = '1234567890';
o.customString.should.equal('1234567890');


Reply to this email directly or view it on GitHub
#10 (comment)
.

I've reproduced the issue and I'm working on fixing it.

Bug fixed and pushed to NPM under version 0.9.1. Thank you for reporting the issue. I've added tests so that any future changes will automatically be tested against this issue-- it won't reoccur.

Thanks for prompt response.

On Wed, Oct 22, 2014 at 11:17 PM, scotthovestadt notifications@github.com
wrote:

Closed #10
#10.


Reply to this email directly or view it on GitHub
#10 (comment)
.