Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extension validation for "cast" #2377

Merged
merged 1 commit into from
Jul 5, 2020

Conversation

bboure
Copy link
Contributor

@bboure bboure commented Jun 4, 2020

Extending Joi to implement a custom cast was not working with the following error:

"cast" is not allowed

Internal validation of extensions was not validating the field.

Example:

Joi.extend((joi) => {
  return {
	  type: 'object',
	  base: joi.object(),
	  cast: {
	    string: {
	      from: (value) => value && typeof value === 'object',
		  to: (value) => JSON.stringify(value),
	    },
	  };
  }
});

@bboure
Copy link
Contributor Author

bboure commented Jun 22, 2020

Any feedback on this?

@hueniverse hueniverse self-assigned this Jul 5, 2020
@hueniverse hueniverse added the feature New functionality or improvement label Jul 5, 2020
@hueniverse hueniverse added this to the 17.1.2 milestone Jul 5, 2020
@hueniverse hueniverse merged commit ab3243d into hapijs:master Jul 5, 2020
hueniverse added a commit that referenced this pull request Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants