Releases: litert/type-guard
Stable Release v1.4.0
Stable Release v1.1.0
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
Changes
- Fixed lack of positive expression when
any
ortrue
is used.
Release v1.0.0
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 ~ 5int(, -10)
means not larget than-10
-
Added length arguments for array types.
e.g.
string[1, 5]
means 1 ~ 5 elementsstring[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
Changes
- Fixed the
undefined
detection.
Release v0.3.0
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
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 fieldmethod
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 ofvoid
andoptional
. -
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
andlatin_string
. -
Removed
ascii_char
andlatin_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
Changes
- Fixed filter "|length".