Skip to content

Add extension validation for "cast"#2377

Merged
hueniverse merged 1 commit intohapijs:masterfrom
bboure:fix/extensionValidator
Jul 5, 2020
Merged

Add extension validation for "cast"#2377
hueniverse merged 1 commit intohapijs:masterfrom
bboure:fix/extensionValidator

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 bboure force-pushed the fix/extensionValidator branch from b3da10e to 3880fd1 Compare June 4, 2020 15:47
@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