Skip to content

Releases: litert/type-guard

Stable Release v1.4.0

26 Jun 10:22
v1.4.0
a5864f1
Compare
Choose a tag to compare

Changes

  • build(project): upgraded toolchains.
  • feat(rules): added supports of modifier $.enum.
  • feat(rules): added supports of using pre-defined type with custom arguments.

Stable Release v1.1.0

22 Mar 08:39
v1.1.0
ad48503
Compare
Choose a tag to compare

Changes:

  • Feature: Now characters -, :, . could be used in names of pre-defined types.
  • Fixed: Incorrect simplifying logic of $.and and $.or.

Release v1.0.1

03 Dec 06:24
Compare
Choose a tag to compare

Changes

  • Fixed lack of positive expression when any or true is used.

Release v1.0.0

05 Apr 04:46
Compare
Choose a tag to compare

Changes

  • A full refactor, with a better and simple code generation.

  • New modifier $.type for pre-defined type supports.

    e.g.

    {
      "a": ["$.type", "test", "string"],
      "b": "@test",
      "c": "@test"
    }

    Register a pre-defined type test, and refers it by @test.

  • New modifier $.string for value in string form.

  • Improved tuple, add omittable dots ... supports.

    e.g. ["$.tuple", "string", "...3", "int", "..."]

  • Replace $.array with $.list.

  • Renamed modifier $.struct to $.strict.

  • New modifier $.equal for recursive edition of $.strict.

  • Now $.array is used for length-fixed or length-variable array.

    e.g.

    • ["$.array", 3, "string"] means 3 elements
    • ["$.array", [3], "string"] means at least 3 elements
    • ["$.array", [3, 5], "string"] means 3 ~ 5 elements
  • Added range arguments for built-in types.

    e.g.

    • string(1, 5) means length 1 ~ 5
    • int(, -10) means not larget than -10
  • Added length arguments for array types.

    e.g.

    • string[1, 5] means 1 ~ 5 elements
    • string[1,] means at least 1 element
  • Added built-in types:

    • safe_int
    • safe_uint
    • ufloat
    • decimal
    • udecimal
    • struct
    • hex_string
    • required
  • Removed built-in types:

    • object
    • valid_object
  • Improved the string assert expressions with following features:

    • equal
    • not-equal
    • equal (case-insensitive)
    • not-equal (case-insensitive)
    • include
    • not-include
    • include (case-insensitive)
    • not-include (case-insensitive)
    • start-with
    • not-start-with
    • start-with (case-insensitive)
    • not-start-with (case-insensitive)
    • end-with
    • not-end-with
    • end-with (case-insensitive)
    • not-end-with (case-insensitive)
    • match (RegExp)
    • not-match (RegExp)

Release v0.3.1

05 Apr 04:51
Compare
Choose a tag to compare

Changes

  • Fixed the undefined detection.

Release v0.3.0

05 Apr 04:52
Compare
Choose a tag to compare

Changes

  • Upgrade TypeScript compiler to v2.9.2.

  • Allowed built-in type in filter:

    To ensure an unsigned integer less than 1000, the rule should be

    ["$.and", "uint", "|value lt 1000"]

    And now, use following rule instead:

    "|uint lt 1000"

Release v0.2.0

06 May 13:44
Compare
Choose a tag to compare

New features

  • Added advanced type $.struct to exactly limit keys of object:

    ["$.struct", {
        "a": "int",
        "b": "string"
    }]

    will not match

    {
        "a": 123,
        "b": "aaa",
        "c": "ddd"
    }

    because only keys "a" and "b" are defined in description.

    Like $.map and $.array, there is a easier notation for it in an object
    description:

    {
        "a->(=)": {
            "b": "string"
        }
    }

    equals to

    {
        "a": ["$.struct", {
            "b": "string"
        }]
    }
  • Added reference field name by syntax $.valueof:field, e.g.

    {
        "method": ["=email", "=password"],
        "$.valueof:method": "string"
    }

    will $.valueof:method means using value of field method as the name of
    a field. Thus it matches

    {
        "method": "email",
        "email": "aaa@sample.com"
    }

    and

    {
        "method": "password",
        "password": "xxxxxxxxx"
    }
  • Added advanced type $.dict to limit keys of $.map:

    ["$.dict", ["a", "b"], "string"]

    is similar to

    ["$.map", "string"]

    but only "a" and "b" is allowed for key of map.

  • Added undefined to built-in-types, as alias of void and optional.

  • Added easier optional type expression with a prepending question mark:

    "?string"
  • Added easier optional field expression with an appending question mark:

    {
        "a?": "string",
        "b": "int",
        "map->{}?": "string"
    }

    This description equals to:

    {
        "a": ["string", "void"],
        "b": "int",
        "map": ["$.map", "string"]
    }
  • Added ascii_string and latin_string.

  • Removed ascii_char and latin_char.

  • Removed the limitation of ONE ARGUMENT for $.array and $.map, so that

    ["$.array", "string", "uint32"]

    is allowed and it works as following code before:

    ["$.array", ["string", "uint32"]]

    Also works for the new $.dict

Release v0.1.1

29 Apr 07:39
Compare
Choose a tag to compare

Changes

  • Fixed filter "|length".