elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
10.27k stars 219 forks source link

validation formats `Unknown format 'hostname'` #578

Closed FDiskas closed 6 months ago

FDiskas commented 6 months ago

What is the problem this feature would solve?

this would allow developer to use common validator formats.

.post('/api/test', ({ body }) => body, {
    body: t.Object({
      test: t.String({
        format: 'hostname',
      }),
    }),
  })

By using this code it will throw an error

Unknown format 'hostname'

What is the feature you are proposing to solve the problem?

I would like to have not only email format but all of them https://ajv.js.org/packages/ajv-formats.html

What alternatives have you considered?

Probably as a developer, I need to read 10 more documentation, install 3 or more additional packages, and bind all those formats for my project

FDiskas commented 6 months ago

How can I add more formats? https://github.com/sinclairzx81/typebox?tab=readme-ov-file#ajv