Super Fast Complex Object Validator for Javascript(& Typescript).

Related tags

Validation safen
Overview

safen

Super Fast Object Validator
for Javascript(& Typescript).

Build Downloads Version License
dependencies Status devDependencies Status

Safen supports the syntax similar to the type script interface. This makes it easy to create validation rules.

1.x

Please check this link for the 1.x version of the README.

How to use

Setup

install,

npm install safen --save

import,

import * as safen from "safen"

// or
const safen = require("safen")

then,

const validator = safen.sfl`{
  username: (string & email & length_between(12, 100)) | null,
  password?: string & length_between(8, 20),
  areas: {
    lat: number & between(-90, 90),
    lng: number & between(-180, 180),
  }[1:] | null,
  env: {
    referer: url,
    ip: ip("v4"),
    os: {
      name: in("window", "osx", "android", "iphone"),
      version: string,
    },
    browser: {
      name: in("chrome", "firefox", "edge", "ie"),
      version: string,
    },
  },
}`

validator.assert({
  username: "[email protected]",
  areas: [
    {lat: 0, lng: 0},
  ],
  env: {
    referer: "http://wan2land.github.io",
    ip: "127.0.0.1",
    os: {
      name: "osx",
      version: "10.13.1",
    },
    browser: {
      name: "chrome",
      version: "62.0.3202.94",
    },
  },
}) // ok

There are two method in Safen, named validate, assert. validate returns boolean and assert throws Exception.

validate method

const validator = safen.sfl<string | null>`(string & email & length_between(12, 100)) | null`

// in javascript,
// const validator = safen.sfl`(string & email & length_between(12, 100)) | null`
// const validator = safen.create(`(string & email & length_between(12, 100)) | null`)

// typescript with Generic
if (validator.validate(data)) {
  // now data is string!
}

validator.validate("[email protected]") // return true
validator.validate(null) // return true

validator.validate("wan2land") // return false, it is not email!

assert method

const validator = safen.sfl<string | null>`(string & email & length_between(12, 100)) | null`

// in javascript,
// const validator = safen.sfl`(string & email & length_between(12, 100)) | null`
// const validator = safen.create(`(string & email & length_between(12, 100)) | null`)

validator.assert("[email protected]") // nothing happens
validator.assert(null) // nothing happens

validator.assert("wan2land") // safen.InvalidValudError occured!

Syntax

Type Syntax

You can easily set the validation by supporting the and, or syntax.

const validator = safen.sfl`{
  username: (string & email & length_between(12, 100)) | null,
}`

validator.assert({
  username: "[email protected]",
}) // ok
validator.assert({
  username: null,
}) // ok

try {
  validator.assert({
    username: "wan2land",
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "username",
        reason: "email",
        params: [],
        message: "The username must be a valid email address.",
      },
      {
        path: "username",
        reason: "null",
        params: [],
        message: "The username must be a null.",
      },
    ])
  }
}

Object Syntax

Optional field

The "?" character can be used to define optional field, which allows no key value or undefined for objects.

const validator = safen.sfl`{
  username: string & length_between(4, 20),
  password?: length_between(8, 20),
}`

validator.assert({
  username: "wan2land",
  password: "password!@#",
}) // ok

validator.assert({
  username: "wan2land",
  // undefined password is OK.
}) // ok

validator.assert({
  username: "wan2land",
  password: undefined, // undefined password is also OK.
}) // ok

try {
  validator.assert({
    // undefined username is not ok.
    password: "password!@#",
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "username",
        reason: "required",
        params: [],
        message: "The username is required.",
      },
    ])
  }
}

try {
  validator.assert({
    username: "wan2land",
    password: null, // null is not allowed
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "password",
        reason: "length",
        params: [],
        message: "The username is required.",
      },
    ])
  }
}

Nested object

Validating nested objects also can be easily done. In addition, the error message makes it easier to check the error path.

const validator = safen.sfl`{
  username: string & length_between(4, 20),
  areas: {
    lat: number & between(-90, 90),
    lng: number & between(-180, 180),
  },
}`

validator.assert({
  username: "wan2land",
  areas: {
    lat: 37,
    lng: 126,
  },
}) // ok

try {
  validator.assert({
    username: "wan2land",
    areas: {
      lat: "37",
      lng: 126,
    },
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas.lat",
        reason: "number",
        params: [],
        message: "The areas.lat must be a number.",
      },
    ])
  }
}

validator.assert({
  username: "wan2land",
  areas: {
    lat: 37,
    lng: 126,
  },
}) // ok

Array Syntax

Simple array

const validator = safen.sfl`{
  areas: {
    lat: number,
    lng: number,
  }[],
}`

validator.assert({
  areas: [], // empty is OK
}) // ok

validator.assert({
  areas: [
    {lat: 37, lng: 126},
    {lat: 31, lng: 125},
  ],
}) // ok

try {
  validator.assert({
    areas: "",
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas",
        reason: "array",
        params: [],
        message: "The areas must be an array.",
      },
    ])
  }
}

Fixed size array

const validator = safen.sfl`{
  areas: {
    lat: number,
    lng: number,
  }[2],
}`

validator.assert({
  areas: [
    {lat: 37, lng: 126},
    {lat: 31, lng: 125},
  ],
}) // ok

try {
  validator.assert({
    areas: [
      {lat: 37, lng: 126},
      {lat: 31, lng: 125},
      {lat: 31, lng: 125},
    ],
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas",
        reason: "array_length",
        params: [2],
        message: "The areas's length must be 2.",
      },
    ])
  }
}

try {
  validator.assert({
    areas: [
      {lat: 37, lng: 126},
    ],
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas",
        reason: "array_length",
        params: [2],
        message: "The areas's length must be 2.",
      },
    ])
  }
}

Array with minimum size

const validator = safen.sfl`{
  areas: {
    lat: number,
    lng: number,
  }[1:],
}`

validator.assert({
  areas: [
    {lat: 31, lng: 125},
  ],
}) // ok

validator.assert({
  areas: [
    {lat: 37, lng: 126},
    {lat: 31, lng: 125},
  ],
}) // ok

try {
  validator.assert({
    areas: [],
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas",
        reason: "array_length_min",
        params: [1],
        message: "The areas's length must be at least 1.",
      },
    ])
  }
}

Array with maximum size

const validator = safen.sfl`{
  areas: {
    lat: number,
    lng: number,
  }[:2],
}`

validator.assert({
  areas: [
    {lat: 31, lng: 125},
  ],
}) // ok

validator.assert({
  areas: [
    {lat: 37, lng: 126},
    {lat: 31, lng: 125},
  ],
}) // ok

try {
  validator.assert({
    areas: [
      {lat: 37, lng: 126},
      {lat: 31, lng: 125},
      {lat: 32, lng: 121},
    ],
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas",
        reason: "array_length_max",
        params: [2],
        message: "The areas's length may not be greater than 2.",
      },
    ])
  }
}

Sized array

const validator = safen.sfl`{
  areas: {
    lat: number,
    lng: number,
  }[1:2],
}`

validator.assert({
  areas: [
    {lat: 31, lng: 125},
  ],
}) // ok

validator.assert({
  areas: [
    {lat: 37, lng: 126},
    {lat: 31, lng: 125},
  ],
}) // ok

try {
  validator.assert({
    areas: [],
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas",
        reason: "array_length_between",
        params: [1, 2],
        message: "The areas's length must be between 1 and 2.",
      },
    ])
  }
}

try {
  validator.assert({
    areas: [
      {lat: 37, lng: 126},
      {lat: 31, lng: 125},
      {lat: 32, lng: 121},
    ],
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas",
        reason: "array_length_between",
        params: [1, 2],
        message: "The areas's length must be between 1 and 2.",
      },
    ])
  }
}

Nested array

const validator = safen.sfl`{
  areas: {
    lat: number,
    lng: number,
  }[][],
}`

validator.assert({
  areas: [
    [
      {lat: 37, lng: 126},
      {lat: 31, lng: 125},
    ],
    [
      {lat: 37, lng: 126},
      {lat: 31, lng: 125},
    ],
  ],
}) // ok

try {
  validator.assert({
    areas: [
      {lat: 37, lng: 126},
      {lat: 31, lng: 125},
    ],
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "areas[0]",
        reason: "array",
        params: [],
        message: "The areas[0] must be an array.",
      },
      {
        path: "areas[1]",
        reason: "array",
        params: [],
        message: "The areas[1] must be an array.",
      },
    ])
  }
}

Custom Tester

Custom tester is written in template format like below:

const oddTester: safen.Tester = (value, params, gen) => {
  return `(Number.isInteger(${value}) && ${value} % 2 === 1)`
}

const evenTester: safen.Tester = (value, params, gen) => {
  return `(Number.isInteger(${value}) && ${value} % 2 === 0)`
}

const validation = safen.create(`{
  even: even,
  odd: odd,
}`, {
  testers: {
    odd: oddTester,
    even: evenTester,
  },
})

expect(validation.validate({even: 2, odd: 1})).toBeTruthy()

expect(validation.validate({even: 1, odd: 1})).toBeFalsy()
expect(validation.validate({even: 2, odd: 2})).toBeFalsy()
expect(validation.validate({even: 1, odd: 2})).toBeFalsy()

A more complex example is:

Custom Error Messages

If needed, you can add custom error messages.

const validator = safen.create(`{
  username: email,
}`, {
  messages: {
    email: [
      "this is a custom error message in :path.", // exist `:path`
      "this is a custom error message.", // no `:path`
    ],
  },
})

try {
  validator.assert({
    username: "wan2land",
  }) // fail
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {
        path: "username",
        reason: "email",
        params: [],
        message: "this is a custom error message in username.",
      },
    ])
  }
}

The :params will be replaced by field name. For example :

const validator = safen.create(`{
  foo: email,
  bar: between(1, 2),
  baz: in("a", "b", "c"),
}`, {
  messages: {
    required: ["The :path is required.", "It is required."],
    between: ["The :path must be between :param0 and :param1.", "It must be between :param0 and :param1."],
    in: ["The :path does not exist in :params.", "It does not exist in :params."],
  },
})

try {
  validator.assert({
    // foo
    bar: 4,
    baz: "d",
  })
} catch (e) {
  if (e instanceof safen.InvalidValueError) {
    expect(e.errors).toEqual([
      {path: "foo", reason: "required", params: [], message: "The foo is required."},
      {path: "bar", reason: "between", params: [1, 2], message: "The bar must be between 1 and 2."},
      {path: "baz", reason: "in", params: ["a", "b", "c"], message: "The baz does not exist in [\"a\",\"b\",\"c\"]."},
    ])
  }
}

Support Validators

Type Validations

Validator Description
bool check if it is a boolean(alias to boolean).
boolean check if it is a boolean.
false check if it is a false.
float check if it is a float(alias to number).
int check if it is a integer(alias to integer).
integer check if it is a integer.
number check if it is a number.
null check if it is a null.
object check if it is a object.
string check if it is a string.
symbol check if it is a symbol.
true check if it is a true.

Other Validations

Validator Description Example
after({date = now}) check if string is a date and is after than specified date. after, after("2017-10-01"), after("2017-10-01 14:30:00")
alpha check if string contains only letters([a-zA-Z]). alpha
alphanum check if string contains only letters and numbers([a-zA-Z0-9]) alphanum
always_false return always false, for debugging. always_false
always_true return always true, for debugging. always_true
any return always true. any
ascii check if string contains only ascii characters. ascii
base64 check if string is Base64. base64
before({date = now}) check if string is a date that's before the specified date. before("2017-10-01"), before("2017-10-01 14:30:00")
between({min},{max}) check if value(string, number) is between {min} and {max}. between("aaa","zzz"), between(1,100)
creditcard check if string is valid Credit Card number. cf. 0000-0000-0000-0000 creditcard
date check if string is valid Date string(RFC2822, ISO8601). cf. 2018-12-25, 12/25/2018, Dec 25, 2018 date
email check if string is valid E-mail string. email
finite check if number is not NaN, Infinity, -Infinity. finite
hexcolor check if string is valid Hex Color string. cf. #ffffff hexcolor
in({...params}) check if value(any) is in an array {params}. in(1,2,3), in("safari","edge","firefox","other browser")
ip({version = all}) check if string is valid UUID.
version is one of all(default), v4, and v6.
ip, ip("v4"), ip("v6")
json check if string is valid JSON. json
jwt check if string is valid JWT. jwt
length({size}) check if value(string)'s length is {size}. length(16)
length_between({min},{max}) check if value(string)'s length is between {min} and {max}. length_between(4,20)
length_max({max}) check if value(string)'s length is less than {max}. length_max(20)
length_min({min}) check if value(string)'s length is greater than {min}. length_min(4)
lowercase check if string is lowercase. lowercase
macaddress check if string is valid Mac Address. macaddress
max({max}) check if value(string, number) is less than {min}. max(5)
min({min}) check if value(string, number) is greater than {max}. min(3)
nan check if value(any) is NaN. nan
re check if value(any) match RegExp(alias to regexp). re(/.+/)
regex check if value(any) match RegExp(alias to regexp). regex(/.+/)
regexp check if value(any) match RegExp. regexp(/.+/)
port check if string is valid PORT(0-65535). port
uppercase check if string is uppercase. uppercase
url check if string is valid URL. url
uuid({version = all}) check if string is valid UUID.
version is one of all(default), v3, v4, and v5.
uuid, uuid("v3"), uuid("v4"), uuid("v5")

Comparison

Using another library? Safen is lot easier to use.

{
  username: (string & email & length_between(12, 100)) | null,
  password?: string & length_between(8, 20),
  areas: {
    lat: number & between(-90, 90),
    lng: number & between(-180, 180),
  }[1:] | null,
  env: {
    referer: url,
    ip: ip("v4"),
    os: {
      name: in("window", "osx", "android", "iphone"),
      version: string,
    },
    browser: {
      name: in("chrome", "firefox", "edge", "ie"),
      version: string,
    },
  },
}

Compare with JSON Schema

Show JSON Schema Source
{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": [
    "username",
    "areas",
    "env"
  ],
  "properties": {
    "username": {
      "type": ["string", "null"],
      "format": "email",
      "minLength": 12,
      "maxLength": 100
    },
    "password": {
      "type": "string",
      "minLength": 8,
      "maxLength": 20
    },
    "areas": {
      "type": ["array", "null"],
      "items": {
        "type": "object",
        "required": [
          "lat",
          "lng"
        ],
        "properties": {
          "lat": {
            "type": "integer",
            "minimum": -90,
            "maximum": 90
          },
          "lng": {
            "type": "integer",
            "minimum": -180,
            "maximum": 180
          }
        }
      }
    },
    "env": {
      "type": "object",
      "required": [
        "referer",
        "ip",
        "os",
        "browser"
      ],
      "properties": {
        "referer": {
          "type": "string",
          "format": "uri"
        },
        "ip": {
          "type": "string",
          "format": "ipv4"
        },
        "os": {
          "type": "object",
          "required": [
            "name",
            "version"
          ],
          "properties": {
            "name": {
              "type": "string",
              "enum": ["window", "osx", "android", "iphone"],
            },
            "version": {
              "type": "string",
              "pattern": "^(.*)$"
            }
          }
        },
        "browser": {
          "type": "object",
          "required": [
            "name",
            "version"
          ],
          "properties": {
            "name": {
              "type": "string",
              "enum": ["chrome", "firefox", "edge", "ie"],
            },
            "version": {
              "type": "string",
              "pattern": "^(.*)$"
            }
          }
        }
      }
    }
  }
}

Compare with JOI

JOI is the most popular object schema validation library.

Show JOI Source
Joi.object().keys({
  username: Joi.string().required().allow(null).email().min(12).max(100),
  password: Joi.string().min(8).max(20),
  areas: Joi.array().required().allow(null).min(1).items(Joi.object().keys({
    lat: Joi.number().required().min(-90).max(90),
    lng: Joi.number().required().min(-180).max(180),
  })),
  env: Joi.object().required().keys({
    referer: Joi.string().uri().required(),
    ip: Joi.string().required().ip({version: ["ipv4"]}),
    os: Joi.object().required().keys({
      name: Joi.any().required().only("window", "osx", "android", "iphone"),
      version: Joi.string().required(),
    }),
    browser: Joi.object().required().keys({
      name: Joi.any().required().only("chrome", "firefox", "edge", "ie"),
      version: Joi.string().required(),
    }),
  }),
})

How Safen works

Safen parses the grammar and internally generates an AST(Abstract Syntax Tree) similar to the Json Schema.

{
  username: (string & email) | null,
  areas: {
    lat?: number & between(-90, 90),
    lng?: number & between(-180, 180),
  }[1]
}

The generated AST is as follows:

Show AST
{
  "type": "object",
  "properties": {
    "username": {
      "optional": false,
      "value": {
        "type": "or",
        "params": [
          {
            "type": "and",
            "params": [
              {
                "type": "scalar",
                "name": "string",
                "params": []
              },
              {
                "type": "scalar",
                "name": "email",
                "params": []
              }
            ]
          },
          {
            "type": "scalar",
            "name": "null",
            "params": []
          }
        ]
      }
    },
    "areas": {
      "optional": false,
      "value": {
        "type": "array",
        "min": 1,
        "max": 1,
        "value": {
          "type": "object",
          "properties": {
            "lat": {
              "optional": true,
              "value": {
                "type": "and",
                "params": [
                  {
                    "type": "scalar",
                    "name": "number",
                    "params": []
                  },
                  {
                    "type": "scalar",
                    "name": "between",
                    "params": [
                      -90,
                      90
                    ]
                  }
                ]
              }
            },
            "lng": {
              "optional": true,
              "value": {
                "type": "and",
                "params": [
                  {
                    "type": "scalar",
                    "name": "number",
                    "params": []
                  },
                  {
                    "type": "scalar",
                    "name": "between",
                    "params": [
                      -180,
                      180
                    ]
                  }
                ]
              }
            }
          }
        }
      }
    }
  }
}

Safen generates native validate and assert functions based on AST, which make safen lightning fast.

Native validate function sample:

Show generated validate function.
function(v) {
  return (function() {
    if (typeof v !== "object" || v === null) {
      return false
    }
    if (typeof v.username === "undefined") {
      return false
    }
    if (!((((typeof(v.username) === "string") && /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v.username)) || v.username === null))) {
      return false
    }
    if (typeof v.areas === "undefined") {
      return false
    }
    if (!((function() {
        if (!Array.isArray(v.areas) || v.areas.length < 1 || v.areas.length > 1) {
          return false
        }
        for (var t0 = 0; t0 < v.areas.length; t0++) {
          if (!((function() {
              if (typeof v.areas[t0] !== "object" || v.areas[t0] === null) {
                return false
              }
              if (typeof v.areas[t0].lat !== "undefined") {
                if (!(((typeof(v.areas[t0].lat) === "number") && (v.areas[t0].lat >= -90 && v.areas[t0].lat <= 90)))) {
                  return false
                }
              }
              if (typeof v.areas[t0].lng !== "undefined") {
                if (!(((typeof(v.areas[t0].lng) === "number") && (v.areas[t0].lng >= -180 && v.areas[t0].lng <= 180)))) {
                  return false
                }
              };
              return true
            })())) {
            return false
          }
        }
        return true
      })())) {
      return false
    };
    return true
  })()
}

Native assert function sample:

Show generated assert function.
function (v) {
  var path = [];
  var errors = (function() {
    var t0 = [];
    if (typeof v !== "object" || v === null) {
      return [{
        message: message(path.join("").replace(/^\./, ""), "object", []),
        path: path.join("").replace(/^\./, ""),
        reason: "object",
        params: []
      }]
    }
    path.push(".username");
    if (typeof v.username !== "undefined") {
      t0 = t0.concat((function() {
        var t1 = [],
          t2 = (function() {
            var t3 = (function() {
              if (!((typeof(v.username) === "string"))) {
                return [{
                  message: message(path.join("").replace(/^\./, ""), "string", []),
                  path: path.join("").replace(/^\./, ""),
                  reason: "string",
                  params: []
                }]
              }
              return []
            })();
            if (t3.length) {
              return t3
            }
            t3 = (function() {
              if (!(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v.username))) {
                return [{
                  message: message(path.join("").replace(/^\./, ""), "email", []),
                  path: path.join("").replace(/^\./, ""),
                  reason: "email",
                  params: []
                }]
              }
              return []
            })();
            if (t3.length) {
              return t3
            }
            return []
          })();
        if (t2.length === 0) {
          return []
        }
        t1 = t1.concat(t2);
        t2 = (function() {
          if (!(v.username === null)) {
            return [{
              message: message(path.join("").replace(/^\./, ""), "null", []),
              path: path.join("").replace(/^\./, ""),
              reason: "null",
              params: []
            }]
          }
          return []
        })();
        if (t2.length === 0) {
          return []
        }
        t1 = t1.concat(t2);
        return t1
      })())
    } else {
      t0.push({
        message: message(path.join("").replace(/^\./, ""), "required", []),
        path: path.join("").replace(/^\./, ""),
        reason: "required",
        params: []
      })
    }
    path.pop();
    path.push(".areas");
    if (typeof v.areas !== "undefined") {
      t0 = t0.concat((function() {
        if (!Array.isArray(v.areas)) {
          return [{
            message: message(path.join("").replace(/^\./, ""), "array", []),
            path: path.join("").replace(/^\./, ""),
            reason: "array",
            params: []
          }]
        }
        if (v.areas.length !== 1) {
          return [{
            message: message(path.join("").replace(/^\./, ""), "array_length", [1]),
            path: path.join("").replace(/^\./, ""),
            reason: "array_length",
            params: [1]
          }]
        }
        var t4 = [];
        for (var t5 = 0; t5 < v.areas.length; t5++) {
          path.push("[" + t5 + "]");
          t4 = t4.concat((function() {
            var t6 = [];
            if (typeof v.areas[t5] !== "object" || v.areas[t5] === null) {
              return [{
                message: message(path.join("").replace(/^\./, ""), "object", []),
                path: path.join("").replace(/^\./, ""),
                reason: "object",
                params: []
              }]
            }
            path.push(".lat");
            if (typeof v.areas[t5].lat !== "undefined") {
              t6 = t6.concat((function() {
                var t7 = (function() {
                  if (!((typeof(v.areas[t5].lat) === "number"))) {
                    return [{
                      message: message(path.join("").replace(/^\./, ""), "number", []),
                      path: path.join("").replace(/^\./, ""),
                      reason: "number",
                      params: []
                    }]
                  }
                  return []
                })();
                if (t7.length) {
                  return t7
                }
                t7 = (function() {
                  if (!((v.areas[t5].lat >= -90 && v.areas[t5].lat <= 90))) {
                    return [{
                      message: message(path.join("").replace(/^\./, ""), "between", [-90, 90]),
                      path: path.join("").replace(/^\./, ""),
                      reason: "between",
                      params: [-90, 90]
                    }]
                  }
                  return []
                })();
                if (t7.length) {
                  return t7
                }
                return []
              })())
            }
            path.pop();
            path.push(".lng");
            if (typeof v.areas[t5].lng !== "undefined") {
              t6 = t6.concat((function() {
                var t8 = (function() {
                  if (!((typeof(v.areas[t5].lng) === "number"))) {
                    return [{
                      message: message(path.join("").replace(/^\./, ""), "number", []),
                      path: path.join("").replace(/^\./, ""),
                      reason: "number",
                      params: []
                    }]
                  }
                  return []
                })();
                if (t8.length) {
                  return t8
                }
                t8 = (function() {
                  if (!((v.areas[t5].lng >= -180 && v.areas[t5].lng <= 180))) {
                    return [{
                      message: message(path.join("").replace(/^\./, ""), "between", [-180, 180]),
                      path: path.join("").replace(/^\./, ""),
                      reason: "between",
                      params: [-180, 180]
                    }]
                  }
                  return []
                })();
                if (t8.length) {
                  return t8
                }
                return []
              })())
            }
            path.pop();
            return t6
          })());
          path.pop()
        }
        return t4
      })())
    } else {
      t0.push({
        message: message(path.join("").replace(/^\./, ""), "required", []),
        path: path.join("").replace(/^\./, ""),
        reason: "required",
        params: []
      })
    }
    path.pop();
    return t0
  })();
  if (errors.length) throw new InvalidValueError(errors)
}

Examples

License

MIT

Comments
  • Update dependency ts-jest to v27 - autoclosed

    Update dependency ts-jest to v27 - autoclosed

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | ts-jest (source) | 26.5.6 -> 27.0.3 | age | adoption | passing | confidence |


    Release Notes

    kulshekhar/ts-jest

    v27.0.3

    Compare Source

    Bug Fixes
    Features

    v27.0.2

    Compare Source

    Bug Fixes

    v27.0.1

    Compare Source

    Bug Fixes

    v27.0.0

    Compare Source

    Bug Fixes
    Features
    Performance Improvements
    Code Refactoring

    BREAKING CHANGES

    • By default, ts-jest will use sourceMap option from your tsconfig. If users want to have sourcemap on, they need to set sourceMap: true in tsconfig.
    • follow Jest support Node engines (#​2478) (1fecf7f)
    • add exports field to package.json, see https://nodejs.org/api/packages.html#packages_package_entry_points (#​2467) (d3aba3e)
    • ts-jest custom AST transformer function signature has changed to
    import type { TsCompilerInstance } from 'ts-jest/dist/types'
    
    export function factory(compilerInstance: TsCompilerInstance) {
       //...
    }
    
    • One is currently using pathRegex should use exclude with glob patterns.
    • If one currently relies on type check for js files, please set checkJs: true in your tsconfig.
    • Now both isolatedModules: true and isolatedModule: false codes are in one single class TsCompiler which is an instance created in TsJestCompiler based on config option compiler with value typescript or ttypescript.
    • config: packageJson config option is not used in internal ts-jest so this option is now removed.
    • config: One is defining ast transformers in jest.config.js/package.json should change to
    // jest.config.js
    module.exports = {
       //...
       globals: {
          'ts-jest': {
             astTransformers: {
               before: ['your_before_transformer_path'],
               after: ['your_after_transformer_path'],
               afterDeclarations: ['your_afterDeclarations_transformer_path'],
             }
          }
       }
    }
    

    or

    // package.json
    {
      "jest": {
         "globals": {
            "ts-jest": {
               "astTransformers": {
                  "before": ["your_before_transformer_path"],
                  "after": ["your_after_transformer_path"],
                  "afterDeclarations": ["your_afterDeclarations_transformer_path"]
               }
            }
         }
      }
    }
    
    • One currently refers type in jest.config.js
    /** @&#8203;typedef {import('ts-jest')} */
    module.exports = {
      //...
    }
    

    should change to

    /** @&#8203;typedef {import('ts-jest/dist/types')} */
    module.exports = {
      //...
    }
    
    • Remove possibilities to import mocked, createJestPreset, pathsToModuleNameMapper from package entry. One should change to
    import { mocked, createJestPreset, pathsToModuleNameMapper } from 'ts-jest/utils'
    
    • config: One currently uses tsConfig should change to tsconfig in your jest.config.js or package.json.

    26.5.6 (2021-05-05)

    Code Refactoring

    Configuration

    πŸ“… Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 2
  • Update dependency eslint-config-stable to v0.10.0

    Update dependency eslint-config-stable to v0.10.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | eslint-config-stable | 0.9.0 -> 0.10.0 | age | adoption | passing | confidence |


    Release Notes

    wan2land/eslint-config-stable

    v0.10.0

    Compare Source


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency eslint to v8

    Update dependency eslint to v8

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | eslint (source) | 7.32.0 -> 8.27.0 | age | adoption | passing | confidence |


    Release Notes

    eslint/eslint

    v8.27.0

    Compare Source

    Features

    Bug Fixes

    • c3ce521 fix: Ensure unmatched glob patterns throw an error (#​16462) (Nicholas C. Zakas)
    • 886a038 fix: handle files with unspecified path in getRulesMetaForResults (#​16437) (Francesco Trotta)

    Documentation

    v8.26.0

    Compare Source

    Features
    • 4715787 feat: check Object.create() in getter-return (#​16420) (Yuki Hirasawa)
    • 28d1902 feat: no-implicit-globals supports exported block comment (#​16343) (Sosuke Suzuki)
    • e940be7 feat: Use ESLINT_USE_FLAT_CONFIG environment variable for flat config (#​16356) (Tomer Aberbach)
    • dd0c58f feat: Swap out Globby for custom globbing solution. (#​16369) (Nicholas C. Zakas)
    Bug Fixes
    • df77409 fix: use baseConfig constructor option in FlatESLint (#​16432) (Milos Djermanovic)
    • 33668ee fix: Ensure that glob patterns are matched correctly. (#​16449) (Nicholas C. Zakas)
    • 740b208 fix: ignore messages without a ruleId in getRulesMetaForResults (#​16409) (Francesco Trotta)
    • 8f9759e fix: --ignore-pattern in flat config mode should be relative to cwd (#​16425) (Milos Djermanovic)
    • 325ad37 fix: make getRulesMetaForResults return a plain object in trivial case (#​16438) (Francesco Trotta)
    • a2810bc fix: Ensure that directories can be unignored. (#​16436) (Nicholas C. Zakas)
    • 35916ad fix: Ensure unignore and reignore work correctly in flat config. (#​16422) (Nicholas C. Zakas)
    Documentation
    Chores

    v8.25.0

    Compare Source

    Features

    Documentation

    Chores

    v8.24.0

    Compare Source

    Features

    Documentation

    Chores

    v8.23.1

    Compare Source

    Bug Fixes

    Documentation

    Chores

    v8.23.0

    Compare Source

    Features

    Documentation

    Chores

    v8.22.0

    Compare Source

    Features

    Documentation

    Chores

    v8.21.0

    Compare Source

    Features

    Bug Fixes

    • 0396775 fix: lines-around-comment apply allowBlockStart for switch statements (#​16153) (Nitin Kumar)

    Documentation

    Chores

    v8.20.0

    Compare Source

    Features

    Bug Fixes

    • 30be0ed fix: no-warning-comments rule escapes special RegEx characters in terms (#​16090) (Lachlan Hunt)
    • bfe5e88 fix: ignore spacing before ] and } in comma-spacing (#​16113) (Milos Djermanovic)

    Documentation

    Chores

    v8.19.0

    Compare Source

    Features

    • 7023628 feat: add importNames support for patterns in no-restricted-imports (#​16059) (Brandon Scott)
    • 472c368 feat: fix handling of blockless with statements in indent rule (#​16068) (Milos Djermanovic)

    Bug Fixes

    • fc81848 fix: throw helpful exception when rule has wrong return type (#​16075) (Bryan Mishkin)

    Documentation

    Chores

    v8.18.0

    Compare Source

    Features

    • a6273b8 feat: account for rule creation time in performance reports (#​15982) (Nitin Kumar)

    Bug Fixes

    • f364d47 fix: Make no-unused-vars treat for..of loops same as for..in loops (#​15868) (Alex Bass)

    Documentation

    Build Related

    Chores

    v8.17.0

    Compare Source

    Features

    • 55319e1 feat: fix indent bug with semicolon-first style (#​15951) (Milos Djermanovic)
    • f6d7920 feat: add allowNamedExports option to no-use-before-define (#​15953) (Milos Djermanovic)

    Bug Fixes

    Documentation

    Chores

    v8.16.0

    Compare Source

    Features

    • cab0c22 feat: add Unicode flag suggestion in no-misleading-character-class (#​15867) (Milos Djermanovic)
    • 38ae956 feat: check Unicode code point escapes in no-control-regex (#​15862) (Milos Djermanovic)
    • ee69cd3 feat: Update global variables (#​15871) (SΓ©bastien RΓ¨gne)

    Bug Fixes

    Documentation

    Chores

    v8.15.0

    Compare Source

    Features
    • ab37d3b feat: add enforceInClassFields option to no-underscore-dangle (#​15818) (Roberto Cestari)
    Bug Fixes
    • 8bf9440 fix: "use strict" should not trigger strict mode in ES3 (#​15846) (Milos Djermanovic)
    Documentation
    Chores

    v8.14.0

    Compare Source

    Features

    Bug Fixes

    • 35fa1dd fix: allow project paths to have URL-encoded characters (#​15795) (Milos Djermanovic)
    • 413f1d5 fix: update astUtils.isDirectiveComment with globals and exported (#​15775) (Milos Djermanovic)

    Build Related

    Chores

    v8.13.0

    Compare Source

    Features

    • 274acbd feat: fix no-eval logic for this in arrow functions (#​15755) (Milos Djermanovic)

    Bug Fixes

    • 97b57ae fix: invalid operator in operator-assignment messages (#​15759) (Milos Djermanovic)

    Documentation

    Chores

    v8.12.0

    [Compare Source](https://togithub.com/eslint/eslint/compare/v8.11.0.


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency ts-jest to v27.0.5

    Update dependency ts-jest to v27.0.5

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | ts-jest (source) | 27.0.4 -> 27.0.5 | age | adoption | passing | confidence |


    Release Notes

    kulshekhar/ts-jest

    v27.0.5

    Compare Source

    Bug Fixes
    Code Refactoring

    Configuration

    πŸ“… Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled due to failing status checks.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency @types/jest to v27

    Update dependency @types/jest to v27

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @types/jest | 26.0.24 -> 27.0.2 | age | adoption | passing | confidence |


    Configuration

    πŸ“… Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update jest monorepo (major)

    Update jest monorepo (major)

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | jest (source) | 26.6.3 -> 27.0.6 | age | adoption | passing | confidence | | ts-jest (source) | 26.5.6 -> 27.0.3 | age | adoption | passing | confidence |


    Release Notes

    facebook/jest

    v27.0.6

    Compare Source

    Fixes
    • [*] Publish all modules to include the build change in #​11569

    v27.0.5

    Compare Source

    Features
    • [@jest/fake-timers] Flush callbacks scheduled with requestAnimationFrame every 16ms when using legacy timers. (#​11523)
    • [pretty-format] Use globalThis (with polyfill if required) to bring support for esbuild's browser bundling mode (#​11569)
    Fixes
    • [jest-core] Support special characters like @, + and () on Windows with --findRelatedTests (#​11548)
    • [@jest/fake-timers] Do not add setImmediate and clearImmediate if they do not exist in the global environment (#​11599)
    • [@jest/reporters] Allow node-notifier@10 as peer dependency (#​11523)
    • [@jest/reporters] Update v8-to-istanbul (#​11523)

    v27.0.4

    Compare Source

    Fixes
    • [jest-config, jest-resolve] Pass in require.resolve to resolvers to resolve from correct base (#​11493)

    v27.0.3

    Compare Source

    Fixes
    • [jest-config] require.resolve on default test sequencer and test environment (#​11482)
    • [jest-mock] Fixed fn and spyOn exports (#​11480)

    v27.0.2

    Compare Source

    Features
    • [jest-circus] Add some APIs to make it easier to build your own test runner
    • [jest-reporters] Expose the getResultHeader util (#​11460)
    • [jest-resolver] Export resolve* utils for different Jest modules (#​11466)
    • [@jest/test-result] Export Test, TestEvents and TestFileEvent (#​11466)
    Fixes
    • [jest-circus] Add missing slash dependency (#​11465)
    • [jest-circus, @&#8203;jest/test-sequencer] Remove dependency on jest-runner (#​11466)
    • [jest-config] Resolve config.runner to absolute path (#​11465)
    • [jest-config] Make sure to support functions as config (#​11475)
    • [jest-core] Do not warn about DNSCHANNEL handles when using the --detectOpenHandles option (#​11470)
    • [jest-runner] Remove dependency on jest-config (#​11466)
    • [jest-worker] Loosen engine requirement to >= 10.13.0 (#​11451)

    v27.0.1

    Compare Source

    Fixes
    • [jest-environment-jsdom] Bump version of JSDOM to avoid deprecated request package (#​11442)

    v27.0.0

    Compare Source

    Features
    • [babel-jest] Add async transformation (#​11192)
    • [jest-changed-files] Use '--' to separate paths from revisions (#​11160)
    • [jest-circus] [BREAKING] Fail tests when multiple done() calls are made (#​10624)
    • [jest-circus, jest-jasmine2] [BREAKING] Fail the test instead of just warning when describe returns a value (#​10947)
    • [jest-config] [BREAKING] Default to Node testing environment instead of browser (JSDOM) (#​9874)
    • [jest-config] [BREAKING] Use jest-circus as default test runner (#​10686)
    • [jest-config] Add support for preset written in ESM (#​11200)
    • [jest-config, jest-runtime] Support ESM for files other than .js and .mjs (#​10823)
    • [jest-config, jest-runtime] [BREAKING] Use "modern" implementation as default for fake timers (#​10874 & #​11197)
    • [jest-config Allow passing forceNodeFilesystemAPI through to jest-haste-map (#​11264)
    • [jest-config, jest-haste-map, jest-resolve, jest-runner, jest-runtime, jest-test-sequencer, jest-transform, jest-types] [BREAKING] Add custom HasteMap class implementation config option (#​11107)
    • [jest-core] make TestWatcher extend emittery (#​10324)
    • [jest-core] Run failed tests interactively the same way we do with snapshots (#​10858)
    • [jest-core] more TestSequencer methods can be async (#​10980)
    • [jest-core] Add support for testSequencer written in ESM (#​11207)
    • [jest-core] Add support for globalSetup and globalTeardown written in ESM (#​11267)
    • [jest-core] Add support for watchPlugins written in ESM (#​11315)
    • [jest-core] Add support for runner written in ESM (#​11232)
    • [jest-core] Add support for reporters written in ESM (#​11427)
    • [jest-each] Add support for interpolation with object properties (#​11388)
    • [jest-environment-node] Add AbortController to globals (#​11182)
    • [@jest/fake-timers] Update to @sinonjs/fake-timers to v7 (#​11198)
    • [jest-haste-map] Handle injected scm clocks (#​10966)
    • [jest-haste-map] Add enableSymlinks configuration option to follow symlinks for test files (#​9351)
    • [jest-repl, jest-runner] [BREAKING] Run transforms over environment (#​8751)
    • [jest-repl] Add support for testEnvironment written in ESM (#​11232)
    • [jest-runner] [BREAKING] set exit code to 1 if test logs after teardown (#​10728)
    • [jest-runner] [BREAKING] Run transforms over runner (#​8823)
    • [jest-runner] [BREAKING] Run transforms over testRunner (#​8823)
    • [jest-runner] Possibility to use ESM for test environment (11033)
    • [jest-runner] Add support for testRunner written in ESM (#​11232)
    • [jest-runtime] Detect reexports from CJS as named exports in ESM (#​10988)
    • [jest-runtime] Support for async code transformations (#​11191 & #​11220)
    • [jest-reporters] Add static filepath property to all reporters (#​11015)
    • [jest-snapshot] [BREAKING] Make prettier optional for inline snapshots - fall back to string replacement (#​7792 & #​11192)
    • [jest-snapshot] [BREAKING] Run transforms over snapshotResolver (#​8751)
    • [jest-transform] Pass config options defined in Jest's config to transformer's process and getCacheKey functions (#​10926)
    • [jest-transform] Add support for transformers written in ESM (#​11163)
    • [jest-transform] [BREAKING] Do not export ScriptTransformer class, instead export the async function createScriptTransformer (#​11163)
    • [jest-transform] Async code transformations (#​9889)
    • [jest-transform] Support transpiled transformers (#​11193)
    • [jest-transform] [BREAKING] requireAndTranspileModule always return a Promise, and the third parameter type is changed to RequireAndTranspileModuleOptions which accept applyInteropRequireDefault option (#​11232)
    • [jest-transform] [BREAKING] createTranspilingRequire return function which return a Promise now (#​11232)
    • [jest-util] add requireOrImportModule for importing CJS or ESM (#​11199)
    • [jest-util] add applyInteropRequireDefault option on requireOrImportModule (#​11232)
    • [jest-watcher] Added support for clearing the line when <C-u> is pressed in a watch mode pattern prompt (#​11358)
    • [jest-worker] Add support for custom task queues and adds a PriorityQueue implementation. (#​10921)
    • [jest-worker] Add in-order scheduling policy to jest worker (10902)
    • [pretty-format] Better print for sparse arrays (11326)
    • [pretty-print] Add option printBasicPrototype which determines whether or not the prototype should be printed for raw objects or arrays (#​11441)
    Fixes
    • [babel-plugin-jest-hoist] Add __dirname and __filename to whitelisted globals (#​10903)
    • [expect] [BREAKING] Revise expect.not.objectContaining() to be the inverse of expect.objectContaining(), as documented. (#​10708)
    • [expect] [BREAKING] Make toContain more strict with the received type (#​10119 & #​10929)
    • [expect] [BREAKING] matcherResult on JestAssertionError are now strings rather than functions (#​10989)
    • [jest-circus] Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped describe block #​10451
    • [jest-circus] Fix testLocation on Windows when using test.each (#​10871)
    • [jest-cli] Use testFailureExitCode when bailing from a failed test (#​10958)
    • [jest-cli] Print custom error if error thrown from global hooks is not an error already (#​11003)
    • [jest-cli] Allow running multiple "projects" from programmatic API (#​11307)
    • [jest-cli] Fix missing collectCoverage after init (#​11353)
    • [jest-cli, jest-config, jest-types] Move all default values into jest-config (#​9924)
    • [jest-config] [BREAKING] Change default file extension order by moving json behind ts and tsx (10572)
    • [jest-console] console.dir now respects the second argument correctly (#​10638)
    • [jest-core] Don't report PerformanceObserver as open handle (#​11123)
    • [jest-core] Use WeakRef to hold timers when detecting open handles (#​11277)
    • [jest-core] Correctly detect open handles that were created in test functions using done callbacks (#​11382)
    • [jest-core] Do not collect RANDOMBYTESREQUEST as open handles (#​11278)
    • [jest-core] Wait briefly for open handles to close before flagging them when using --detectOpenHandles (#​11429)
    • [jest-diff] [BREAKING] Use only named exports (#​11371)
    • [jest-each] [BREAKING] Ignore excess words in headings (#​8766)
    • [jest-each] Support array index with template strings (#​10763)
    • [jest-each] Interpolate %% correctly (#​11364)
    • [jest-each] Fix wrong interpolation when the value of array contains multiple % (#​11364)
    • [jest-environment] [BREAKING] Drop support for runScript for test environments (#​11155)
    • [jest-environment-jsdom] Use inner realm’s ArrayBuffer constructor (#​10885)
    • [jest-environment-jsdom] [BREAKING] Remove Node globals setImmediate and clearImmediate #​11222
    • [jest-get-type] [BREAKING] Convert to ES Module (#​11359)
    • [jest-globals] [BREAKING] Disallow return values other than a Promise from hooks and tests (#​10512)
    • [jest-globals] [BREAKING] Disallow mixing a done callback and returning a Promise from hooks and tests (#​10512)
    • [jest-haste-map] Vendor NodeWatcher from sane (#​10919)
    • [jest-jasmine2] Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped describe block when it has child tests marked as either only or todo #​10451
    • [jest-jasmine2] Fixed the issues of child tests marked with only or todo getting executed even if it is inside a skipped parent describe block #​10451
    • [jest-jasmine2] Wrap all test functions so they open handles that were created in test functions using done callbacks can be detected (#​11382)
    • [jest-reporter] Handle empty files when reporting code coverage with V8 (#​10819)
    • [jest-resolve] Replace read-pkg-up with escalade package (#​10781)
    • [jest-resolve] Disable jest-pnp-resolver for Yarn 2 (#​10847)
    • [jest-runtime] [BREAKING] Do not inject global variable into module wrapper (#​10644)
    • [jest-runtime] [BREAKING] remove long-deprecated jest.addMatchers, jest.resetModuleRegistry, and jest.runTimersToTime (#​9853)
    • [jest-runtime] Fix stack overflow and promise deadlock when importing mutual dependant ES module (#​10892)
    • [jest-runtime] Prevent global module registry from leaking into isolateModules registry (#​10963)
    • [jest-runtime] Refactor to prevent race condition when linking and evaluating ES Modules (#​11150)
    • [jest-runtime] Throw correct error when attempting to load ESM via require (#​11260)
    • [jest-runtime] Do not cache modules that throw during evaluation (#​11263)
    • [jest-transform] Show enhanced SyntaxError message for all SyntaxErrors (#​10749)
    • [jest-transform] [BREAKING] Refactor API to pass an options bag around rather than multiple boolean options (#​10753)
    • [jest-transform] [BREAKING] Refactor API of transformers to pass an options bag rather than separate config and other options (#​10834)
    • [jest-types] Fix Config.ts projects types (#​11285)
    • [jest-util] Replace micromatch with picomatch to fix issues with negated globs (#​11287)
    • [jest-validate] Use en-US locale to avoid case conversion problems while validating CLI options on machines with some certain locales(e.g. Turkish) set as default locale. (#​11412)
    • [jest-worker] [BREAKING] Use named exports (#​10623)
    • [jest-worker] Do not swallow errors during serialization (#​10984)
    • [jest-worker] Handle ERR_IPC_CHANNEL_CLOSED errors properly (#​11143)
    • [pretty-format] [BREAKING] Convert to ES Modules (#​10515)
    • [pretty-format] Only call hasAttribute if it's a function (#​11000)
    • [pretty-format] Handle jsdom attributes properly (#​11189)
    • [pretty-format] Import pretty-format using named imports (#​11360)
    Chore & Maintenance
    • [*] [BREAKING] Only support Node LTS releases and Node 15 (#​10685)
    • [*] [BREAKING] Add exports field to all package.jsons (#​9921)
    • [*] Make it easier for Jest's packages to use the VM escape hatch (#​10824)
    • [*] [BREAKING] Remove deprecated mapCoverage (#​9968)
    • [babel-jest] [BREAKING] Migrate to ESM (#​11193)
    • [docs] Correct example using browser-resolve (#​11140)
    • [docs] Clarify timers configuration property (#​11376)
    • [jest, jest-core] [BREAKING] Replace TestScheduler export with createTestScheduler (#​11427)
    • [jest-config] [BREAKING] Remove enabledTestsMap config, use filter instead (#​10787)
    • [jest-console] [BREAKING] Move root into config and take GlobalConfig as mandatory parameter for getConsoleOutput (#​10126)
    • [jest-console] Export LogEntry (#​11017)
    • [jest-fake-timers] Clarify global behavior of jest.useFakeTimers and jest.useRealTimers (#​10867)
    • [jest-haste-map] [BREAKING] Migrate to ESM (#​10875)
    • [jest-haste-map] [BREAKING] Remove support for deprecated option ignorePattern as function (#​10348)
    • [jest-jasmine2] [BREAKING] Migrate to ESM (#​10906)
    • [jest-jasmine2] [BREAKING] Remove unused options argument from Env constructor (#​10240)
    • [jest-repl, jest-runtime] [BREAKING] Move the jest-runtime CLI into jest-repl (#​10016 & #​10925)
    • [jest-resolve] [BREAKING] Migrate to ESM (#​10688)
    • [jest-resolve-dependencies] [BREAKING] Migrate to ESM (#​10876)
    • [jest-mock] [BREAKING] Migrate to ESM (#​10887)
    • [jest-reporters] [BREAKING] Make node-notifier a peer dependency (#​10977)
    • [jest-resolve, jest-runtime] [BREAKING] Use Maps instead of objects for all cached resources (#​10968)
    • [jest-runner] [BREAKING] Migrate to ESM (#​10900)
    • [jest-runtime] [BREAKING] Remove deprecated and unused getSourceMapInfo from Runtime (#​9969)
    • [jest-transformer] [BREAKING] Remove unused isCoreModule option (#​11166)
    • [jest-util] No longer checking enumerable when adding process.domain (#​10862)
    • [jest-validate] [BREAKING] Remove recursiveBlacklist option in favor of previously introduced recursiveDenylist (#​10650)
    • [website] Replace 'Github' with 'GitHub' (#​11279)
    • [website] Remove a language code from the link to the Node.js website (#​11282)
    • [website] Remove a duplicated word (#​11281)
    • [website] Add french to website (#​11361)
    Performance
    • [jest-resolve] Cache reading and parsing of package.jsons (#​11076)
    • [jest-runtime, jest-transform] share cacheFS between runtime and transformer (#​10901)
    • [jest-runtime] Load chalk only once per worker (#​10864)
    • [jest-worker] Fix memory leak of previous task arguments while no new task is scheduled (#​11187)
    kulshekhar/ts-jest

    v27.0.3

    Compare Source

    Bug Fixes
    Features

    v27.0.2

    Compare Source

    Bug Fixes

    v27.0.1

    Compare Source

    Bug Fixes

    v27.0.0

    Compare Source

    Bug Fixes
    Features
    Performance Improvements
    Code Refactoring

    BREAKING CHANGES

    • By default, ts-jest will use sourceMap option from your tsconfig. If users want to have sourcemap on, they need to set sourceMap: true in tsconfig.
    • follow Jest support Node engines (#​2478) (1fecf7f)
    • add exports field to package.json, see https://nodejs.org/api/packages.html#packages_package_entry_points (#​2467) (d3aba3e)
    • ts-jest custom AST transformer function signature has changed to
    import type { TsCompilerInstance } from 'ts-jest/dist/types'
    
    export function factory(compilerInstance: TsCompilerInstance) {
       //...
    }
    
    • One is currently using pathRegex should use exclude with glob patterns.
    • If one currently relies on type check for js files, please set checkJs: true in your tsconfig.
    • Now both isolatedModules: true and isolatedModule: false codes are in one single class TsCompiler which is an instance created in TsJestCompiler based on config option compiler with value typescript or ttypescript.
    • config: packageJson config option is not used in internal ts-jest so this option is now removed.
    • config: One is defining ast transformers in jest.config.js/package.json should change to
    // jest.config.js
    module.exports = {
       //...
       globals: {
          'ts-jest': {
             astTransformers: {
               before: ['your_before_transformer_path'],
               after: ['your_after_transformer_path'],
               afterDeclarations: ['your_afterDeclarations_transformer_path'],
             }
          }
       }
    }
    

    or

    // package.json
    {
      "jest": {
         "globals": {
            "ts-jest": {
               "astTransformers": {
                  "before": ["your_before_transformer_path"],
                  "after": ["your_after_transformer_path"],
                  "afterDeclarations": ["your_afterDeclarations_transformer_path"]
               }
            }
         }
      }
    }
    
    • One currently refers type in jest.config.js
    /** @&#8203;typedef {import('ts-jest')} */
    module.exports = {
      //...
    }
    

    should change to

    /** @&#8203;typedef {import('ts-jest/dist/types')} */
    module.exports = {
      //...
    }
    
    • Remove possibilities to import mocked, createJestPreset, pathsToModuleNameMapper from package entry. One should change to
    import { mocked, createJestPreset, pathsToModuleNameMapper } from 'ts-jest/utils'
    
    • config: One currently uses tsConfig should change to tsconfig in your jest.config.js or package.json.

    26.5.6 (2021-05-05)

    Code Refactoring

    Configuration

    πŸ“… Schedule: At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ‘» Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, check this box.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency jest to v25.5.4

    Update dependency jest to v25.5.4

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | jest (source) | devDependencies | minor | 25.4.0 -> 25.5.4 |


    Release Notes

    facebook/jest

    v25.5.4

    Compare Source

    Fixes
    • [jest-jasmine2] Don't run beforeAll / afterAll in skipped describe blocks (#​9931)
    Chore & Maintenance
    • [jest-runtime] Do not warn when mutating require.cache (#​9946)

    v25.5.3

    Compare Source

    Chore & Maintenance
    • [jest-circus] Fix memory leak when running in band (#​9934)

    v25.5.2

    Compare Source

    Fixes
    • [jest-globals] Export globals as values, not types (#​9925)

    v25.5.1

    Compare Source

    Fixes
    • [jest-haste-map] Add missing @types/graceful-fs dependency (#​9913)
    • [jest-runner] Correctly serialize Set passed to worker (#​9915)
    • [jest-runtime] Vary ESM cache by query (#​9914)

    v25.5.0

    Compare Source

    Features
    • [@jest/globals] New package so Jest's globals can be explicitly imported (#​9801)
    • [jest-core] Show coverage of sources related to tests in changed files (#​9769)
    • [jest-runtime] Populate require.cache (#​9841)
    Fixes
    • [*] Use graceful-fs directly in every package instead of relying on fs being monkey patched (#​9443)
    • [expect] Prints the Symbol name into the error message with a custom asymmetric matcher (#​9888)
    • [jest-circus, jest-jasmine2] Support older version of jest-runtime (#​9903 & #​9842)
    • [@jest/environment] Make sure not to reference Jest types (#​9875)
    • [jest-message-util] Code frame printing should respect --noStackTrace flag (#​9866)
    • [jest-runtime] Support importing CJS from ESM using import statements (#​9850)
    • [jest-runtime] Support importing parallel dynamic imports (#​9858)
    • [jest-transform] Improve source map handling when instrumenting transformed code (#​9811)
    Chore & Maintenance
    • [docs] Add an example for mocking non-default export class
    Performance
    • [jest-resolve] Update resolve to a version using native realpath, which is faster than the default JS implementation (#​9872)
    • [jest-resolve] Pass custom cached realpath function to resolve (#​9873)
    • [jest-runtime] Add teardown method to clear any caches when tests complete (#​9906)
    • [jest-runtime] Do not pass files required internally through transformation when loading them (#​9900)
    • [jest-runtime] Use Maps instead of object literals as cache holders (#​9901)

    Renovate configuration

    :date: Schedule: At any time (no schedule defined).

    :vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

    :recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    :no_bell: Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Update dependency typescript to v4.9.3

    Update dependency typescript to v4.9.3

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | typescript (source) | 4.8.4 -> 4.9.3 | age | adoption | passing | confidence |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update babel monorepo to v7.20.2

    Update babel monorepo to v7.20.2

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @babel/core (source) | 7.19.6 -> 7.20.2 | age | adoption | passing | confidence | | @babel/plugin-proposal-object-rest-spread (source) | 7.19.4 -> 7.20.2 | age | adoption | passing | confidence | | @babel/preset-env (source) | 7.19.4 -> 7.20.2 | age | adoption | passing | confidence |


    Release Notes

    babel/babel

    v7.20.2

    Compare Source

    :bug: Bug Fix
    • babel-core, babel-helper-create-class-features-plugin, babel-helper-module-transforms, babel-helper-plugin-utils, babel-helper-simple-access, babel-node, babel-plugin-transform-block-scoping, babel-plugin-transform-classes, babel-plugin-transform-react-constant-elements, babel-preset-env, babel-standalone, babel-types
    • babel-plugin-transform-typescript
    • babel-parser
    • babel-generator
    • babel-plugin-proposal-decorators, babel-plugin-proposal-object-rest-spread, babel-plugin-transform-jscript
    • babel-plugin-transform-destructuring

    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update dependency @types/node to v14.18.33

    Update dependency @types/node to v14.18.33

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @types/node (source) | 14.18.32 -> 14.18.33 | age | adoption | passing | confidence |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Enabled.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update dependency @types/node to v18

    Update dependency @types/node to v18

    Mend Renovate

    This PR contains the following updates:

    | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | @types/node (source) | 14.18.33 -> 18.11.9 | age | adoption | passing | confidence |


    Configuration

    πŸ“… Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    β™» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    πŸ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
Owner
Changwan Jun
Computer-Illiterate. JS, a little bit.
Changwan Jun
ForgJs is a javascript lightweight object validator. Go check the Quick start section and start coding with love

Hey every one im really happy that this repo reached this many stars ?? ,but this repo needs your contibution I started to better document the code th

Hamdaoui Oussama 1.7k Dec 21, 2022
A JSONSchema validator that uses code generation to be extremely fast

is-my-json-valid A JSONSchema validator that uses code generation to be extremely fast. It passes the entire JSONSchema v4 test suite except for remot

Mathias Buus 948 Dec 31, 2022
Fast, compiled, eval-free data validator/transformer

spectypes Fast, compiled, eval-free data validator/transformer Features really fast, can be even faster than ajv detailed errors, failure will result

null 65 Dec 29, 2022
Simple password validator made with Javascript πŸ’›

Password Validator Simple password validator made with Javascript ?? Branch history base-code: a complex logic to password validator. In next branches

Lais FrigΓ©rio 8 Jul 25, 2022
Copypaster Has your project structure gotten so complex that to add a new feature you need to copy

Copypaster Has your project structure gotten so complex that to add a new feature you need to copy, paste and rename tens or hundreds of files each ti

null 2 Nov 4, 2022
The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)

Ajv JSON schema validator The fastest JSON validator for Node.js and browser. Supports JSON Schema draft-06/07/2019-09/2020-12 (draft-04 is supported

Ajv JSON schema validator 12k Jan 4, 2023
Tiny Validator for JSON Schema v4

Tiny Validator (for v4 JSON Schema) Use json-schema draft v4 to validate simple values and complex objects using a rich validation vocabulary (example

Geraint 1.2k Dec 21, 2022
Simple validator for Steuerliche Identifikationsnummer (German personal tax number) according to the official docs (see readme).

simple-de-taxid-validator Important Code of this validator is taken (with small changes like optimization or removing not needed elements) from THIS R

Wojciech 3 Feb 24, 2022
Easy HTML Form Validator

Easy HTML Form Validator

Ali Nazari 314 Dec 26, 2022
A simple environment variables validator for Node.js and web browsers

A simple environment variables validator for Node.js and web browsers

Mathieu Acthernoene 25 Jul 20, 2022
Facile is an HTML form validator that is inspired by Laravel's validation style and is designed for simplicity of use.

Facile is an HTML form validator that is inspired by Laravel's validation style and is designed for simplicity of use.

upjs 314 Dec 26, 2022
What does the Cosmos Hub validator set looks like without ICF delegations?

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Made in Block 2 Sep 2, 2022
This is the code repository of the official mun testnet validator node source code.

How to join Munchain network Infrastructure **Recommended configuration:** - Number of CPUs: 4 - Memory: 16GB - OS: Ubuntu 22.04 LTS - Allow all incom

MUN Blockchain 16 Dec 15, 2022
Dead simple Object schema validation

Yup Yup is a JavaScript schema builder for value parsing and validation. Define a schema, transform a value to match, validate the shape of an existin

Jason Quense 19.2k Jan 2, 2023
A simple and composable way to validate data in JavaScript (and TypeScript).

A simple and composable way to validate data in JavaScript (and TypeScript). Usage β€’ Why? β€’ Principles β€’ Demo β€’ Examples β€’ Documentation Superstruct m

Ian Storm Taylor 6.3k Jan 9, 2023
🦩 Joi like validations for TypeScript

?? Computed Types Runtime validation types for TypeScript. Computed-Types (formerly: Funval) is a strongly-typed validation library for TypeScript. Us

Neuledge 338 Jan 4, 2023
TypeScript-first schema validation for h3 and Nuxt applications

h3-zod Validate h3 and Nuxt 3 requests using zod schema's. Install npm install h3-zod Usage import { createServer } from 'http' import { createApp } f

Robert Soriano 48 Dec 28, 2022
Validate your forms, frontend, without writing a single line of javascript

Parsley JavaScript form validation, without actually writing a single line of JavaScript! Version 2.9.2 Doc See index.html and doc/ Requirements jQuer

Guillaume Potier 9k Dec 27, 2022
Lightweight JavaScript form validation library inspired by CodeIgniter.

validate.js validate.js is a lightweight JavaScript form validation library inspired by CodeIgniter. Features Validate form fields from over a dozen r

Rick Harrison 2.6k Dec 15, 2022