fabian-hiller / valibot

The modular and type safe schema library for validating structural data 🤖
https://valibot.dev
MIT License
6k stars 186 forks source link

Suggestion to Use nil Instead of null_ for Primitive Value #656

Closed ksamirdev closed 3 months ago

ksamirdev commented 3 months ago

I would like to propose using nil as a replacement for null_ for primitive values. This change would provide better clarity and readability.

fabian-hiller commented 3 months ago

Thank you for your feedback! Is it because of the underscore? If so, note that there are a few more schemas with the underscore suffix. nil is not part of JavaScript and TypeScript. That's why I used null_ instead.

ksamirdev commented 3 months ago

I think It will also valid if its in uppercase, NULL

fabian-hiller commented 3 months ago

That's true but that we have a mix of lowercase and uppercase names for similar things. I prefer the underscore suffix in this case.

fabian-hiller commented 3 months ago

But what we can do is to add the alias export export { null_ as null }; to the end of the null.ts file. Using a wildcard import you can write v.null() this way. It only does not work for direct imports.

fabian-hiller commented 3 months ago

The only confusing thing might be that VS Code recommends both v.null and v.null_ when typing the function.