Skip to content

Can we dynamically generate verification rules in a way similar to json schema? #1050

Open
@libondev

Description

I want to generate a verification object from a serialized object, for example, the following input (which may not be described completely or accurately):

{
  "name": {
    "type": "string",
    "minLength": 2
  },
  "age": {
    "type": "number",
    "minValue": 10
  },
  ...
}

generate a validator with the same effect as the following rules:

v.object({
  name: v.pipe(v.string(), v.minLength(2)),
  age: v.pipe(v.number(), v.minValue(10)),
  email: v.pipe(
    v.string(),
    v.minLength(5),
    v.email(),
    v.endsWith('@example.com')
  )
})

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions