sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.81k stars 108 forks source link

Retrieve expected type `ow` validated #197

Closed sundaycrafts closed 3 years ago

sundaycrafts commented 3 years ago

I'm sorry if it had already discussed but I thought it would be great if ow has a function to retrieve the type ow validated like a Superstruct's infer.

Is it already planned? Or maybe it is not this project's goal🤔

sindresorhus commented 3 years ago

I think that could be useful.

jorisre commented 3 years ago

@sindresorhus Regarding the expected API. Does something like that is good for you?

import ow, { Infer } from 'ow';

const schema = ow.object.exactShape({
  name: ow.string
});

type Schema = Infer<typeof schema>;