Skip to content

Add Joi.class()#1305

Closed
wswoodruff wants to merge 7 commits intohapijs:masterfrom
wswoodruff:add-class-validation
Closed

Add Joi.class()#1305
wswoodruff wants to merge 7 commits intohapijs:masterfrom
wswoodruff:add-class-validation

Conversation

@wswoodruff
Copy link
Contributor

@wswoodruff wswoodruff commented Sep 16, 2017

  • Add Joi.class()
  • Ensure regular functions are not valid as Joi.class()
  • Ensure ES6 classes are not valid as Joi.func()
  • Ensure ES6 classes validate correctly with Joi.class()

BREAKING CHANGE: joi users might have been passing in ES6 classes to Joi.func(), and this will cause a validation error now.

@wswoodruff wswoodruff changed the title Add class validation Add ES6 class validation Sep 16, 2017
@devinivy
Copy link
Member

devinivy commented Sep 18, 2017

Currently Joi.[type]() reflects the intended type of the value being validated. To stay consistent with that and avoid a breaking change, perhaps the API should be Joi.func().class() (given that a class is of type 'function').

@wswoodruff
Copy link
Contributor Author

Ooh sounds like a good idea!

@WesTyler
Copy link
Contributor

+1 on @devinivy 's proposed API.

@wswoodruff
Copy link
Contributor Author

Ok I'm gonna redo this real quick

@wswoodruff wswoodruff closed this Sep 19, 2017
@wswoodruff wswoodruff deleted the add-class-validation branch September 19, 2017 01:42
@wswoodruff wswoodruff changed the title Add ES6 class validation Add Joi.class() Oct 5, 2017
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants