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

Have assertString.js provide the invalid type passed to validator. #895

Merged
merged 7 commits into from
Sep 24, 2018
Merged

Have assertString.js provide the invalid type passed to validator. #895

merged 7 commits into from
Sep 24, 2018

Conversation

DCtheTall
Copy link
Contributor

As discussed in issue #894 I thought it would be useful for assertString.js to provide which invalid type was used as an input.

It checks explicitly for null, otherwise it will use typeof input. If typeof input === 'object' it will use the object's constructor's name (since 'object' alone is rarely helpful), though if that seems like overkill I can take that out.

invalidType = `a ${invalidType}`;
}
}
let message = 'This library (validator.js) validates strings only, ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the message just be this, to make it less verbose:

`Expected string but received ${invalidType}`

lib/util/assertString.js Show resolved Hide resolved
Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

@profnandaa
Copy link
Member

Thanks for your contribution @DCtheTall 🎉

Please check my comments above.

@DCtheTall
Copy link
Contributor Author

@profnandaa ready for another look when you can.

@profnandaa
Copy link
Member

profnandaa commented Sep 24, 2018 via email

@profnandaa
Copy link
Member

@DCtheTall -- thanks for getting your first contribution in! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants