feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.03k stars 747 forks source link

Export Typebox Conditional ? #2947

Closed tvld closed 1 year ago

tvld commented 1 year ago

Right now I use :

'''ts import { StringEnum } from '@feathersjs/typebox' import { Conditional } from '@sinclair/typebox/conditional' ''' Maybe it would be nice to stick to pattern?

import { StringEnum, Conditional } from '@feathersjs/typebox'

Maybe convenient in node_modules/@feathersjs/typebox/lib/index.d.ts add:

export * from '@sinclair/typebox/conditional';   
tvld commented 1 year ago

Going to close it already. I realize that my whole idea to conditionally exclude a character with this does not work:

export const ImageBaseNameSchema = Conditional.Exclude(
  Type.String({ maxLength: 100 }), // fails... my bad ;)
  Type.Literal('.') 
  )

I will use regex instead to have a base file name without the extension, to force "my-image" and prevent "my-image.jpg":

Type.String({ pattern: '^([^.]+)$', maxLength: 100 })