Would be nice to have. This is currently the only thing that blocks us from upgrading to 16.
Can i start on this?
@asingh04 Sure!
Can i start on this?
That would be awesome!
Thanks @kirillgroshkov , I will ping you with queries and doubts as I will encounter them.
Hey guys, is there any progress on this?
We're still blocked by this. Actually, the only important custom validator that we need to implement is dateString(minDate, maxDate), that should check that given string is a correct ISO8601 date and within the min/max date range. I know how to do the actual date conversions/checks (no problem there), but I don't fully understand how to use Joi API to register such "extension", with these parameters, use them inside the validator and throw errors with text messages that use input parameters (e.g "date should be after 2012-06-21").
Anyone can help to point me in the right direction?
UPD: opened a separate issue about it now: https://github.com/hapijs/joi/issues/2322
UPD2: I've solved my dateString extension case in the issue above. API docs looked a bit more clear after spending some more hours on it.
@hueniverse @asingh04 How should args look? I keep getting errors since there's no documentation. Any simple example you can give so we can at least get started?
Joi.extend((joi) => {
return {
type: 'testtype',
// more
rules: {
testrule: {
args: [
// what should this look like?
],
// more
},
},
}
})
```
@rightaway I found @types/hapi__joi immensely useful when trying to dig the API. Seems like many things were already "documented" there.
@kirillgroshkov May I draw your attention to this paragraph from the v16 release notes:
Migrating existing extensions is outside the scope of this guide. Please consult the documentation when it becomes available. However, the best resource is the joi built-in types code base.
Looking at the code for the date type should help you answer your questions.
@hueniverse Hello, I think I have a pretty good understanding on how extensions work, mind if I get started?
@dreamsinspace sure.
@hueniverse Lovely. Where do I ask for help in case I'm unsure about something?
Slack is best.
Do we have a working in progress pull request I can looking at? Already working on writing extensions.
@wy193777 Not really, I'm working locally. We could exchange ideas on slack if you wish
cound't find documention of old version also.
I'm sorry but how in god's name did someone deem this new API suitable to go out in a new major release without proper documentation? That should have been a hard blocker on this. Obviously once it was released no-one was going to have the impetus to document this properly. And now it has been __14 MONTHS__ since release and the docs are still full of TODO. Look, I know this is a free library and I hate people complaining about open source projects as much as the next guy, but that breaks down when given the choice to _do nothing_ (i.e. don't update the extension system) or do a half-assed job (update it without full documentation), doing the latter is actively a more hostile thing to do鈥攏o-one asked for this extensions overhaul so if you're going to do it, do it with proper documentation.
@leonaves
I'm sorry
Starting right off with a barefaced lie is a classy way to engage.
I hate people complaining about open source projects as much as the next guy
Seriously?! What an absurd thing to say in what is literally a long entitled rant - only made worse by being fully self-aware of how entitled and hostile you are.
when given the choice to do nothing
How is that different from your own choice to do nothing?! Seriously, who exactly is making you upgrade? Go ahead and do nothing and keep using the version that you felt was already solving your problems sufficiently.
I feel embarrassed for you.
I'm sorry but how in god's name did someone deem this new API suitable to go out in a new major release without proper documentation
If there are tests, it's ready... They're one of the best forms of documentation out there and probably all you need, eg: https://github.com/sideway/joi/blob/master/test/extend.js ... Also, count on Eran / Hapi tests to be pretty solid because they are. Many times docs are trash and you have to figure it out via examples. Ever tried to implement some googleapi stuff? Their docs are kindof sucky, but their tests give fantastic config and usage examples. Hapi had some hidden functionality that was undocumented but had tests... tests made it as easy as copy pasta. Sometimes you just have to use half your brain when you're programming.
Most helpful comment
Would be nice to have. This is currently the only thing that blocks us from upgrading to 16.