ostrowr / ts-json-validator

Let JSON play nicely with Typescript
MIT License
342 stars 7 forks source link

[BUG] String methods are mixed in #53

Open moltar opened 3 years ago

moltar commented 3 years ago

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/**/*"
  ]
}