ostrowr/ts-json-validator

[BUG] String methods are mixed in

moltar opened this issue · 0 comments

  • Before submitting a bug report, double-check that your Typescript version is at least 3.7.

Describe the bug

I am seeing String methods are mixed in with the object properties.

To Reproduce

import { createSchema, TsjsonParser } from "ts-json-validator"

const username = createSchema({ type: "string", minLength: 2 })
const password = createSchema({ type: "string" })

export const register = createSchema({
  type: "object",
  properties: {
    username,
    password,
  },
  required: ["username", "password"]
})

const registerParser = new TsjsonParser(register)
const body = registerParser.parse('{}')

Expected behavior

To have only username and password props.

Actual behavior

Lots of unrelated props, from the String object.

Screenshots

screenshot-20211006T124310-BMsyOhDz

Additional context

packages:

    "typescript": "4.4.3"
    "ts-json-validator": "0.7.1",
    "tsconfigs": "5.0.0"

tsconfig.json

{
  "extends": "tsconfigs/agnostic-module",
  "compilerOptions": {
    "jsx": "react"
  },
  "include": [
    "src/**/*",
    "lambda/**/*"
  ]
}