Skip to content

Releases: moshegottlieb/ts-json-object

Reflect metadata package update

28 Jun 07:46
Compare
Choose a tag to compare

Update reflect-metadata (the only dependency) to the latest version

Added `minLength` and `maxLength`

24 Jun 07:36
Compare
Choose a tag to compare

Long overdue, added minLength and maxLength decorators.

class Person extends JSONObject {
    @minLength(5)
    @maxLength(10)
    name:string
}

let p:Person

p = new Person({
    name: 'foo'
}) // will throw an error, too short

p = new Person({
    name: '1234567890 too long'
}) // will throw an error, too long

p = new Person({}) // ok, optional by default
p = new Person({'
    name:'Dilbert'
}') // ok, length is 7

Also works on arrays:

class Person extends JSONObject {
    @minLength(1)
    @maxLength(3)
    traits:string[]
}

let p:Person
p = new Person({
    traits: ['kind','strong']
}) // OK, two traits

p = new Person({
        traits: ['kind','strong','fast','slow']
}) // will throw an error, too many traits

Fix #4 - @array validation does not work on empty objects

16 Jun 13:10
Compare
Choose a tag to compare

Fixed wrong null explicit assignment

07 Oct 15:10
Compare
Choose a tag to compare
class Nullable extends JSONObject {
    @optional
    value?:string;
}
let n = new Nullable({ "value":null })
// this would result in n.value == "null" (as string)
// this release fixes this bug 

v0.2.9

16 Jun 14:26
Compare
Choose a tag to compare
Merge branch 'master' of github.com:moshegottlieb/ts-json-object

Inheritance issue fixes

20 May 07:58
Compare
Choose a tag to compare

This release fixes an issue with inheritance.
In previous versions, the list of keys for a given class was common for all descendants of a given base class, which is of course, plain wrong.

Better date validation

19 May 11:42
Compare
Choose a tag to compare
class DateTest extends JSONObject {
            @required
            date:Date
}
// Works! anything that works with a Date CTOR should work
let test1 = new DateTest({date:1}) 
// Will throw an error! date is invalid
let test2 = new DateTest({date: 'not going to work'})