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

Slightly better error messages #451

Merged
merged 5 commits into from
Nov 13, 2018
Merged

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented Nov 12, 2018

Fixes #436 and https://b.corp.google.com/issues/78932093

This PR:

  • adds the field path to the error message if a field-level validation fails
  • uses consistent quotes in all errors (changed single quotes to double)
  • enforces that all errors are verified as they are raised by removing the RegExp matching and matching by exact value instead

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 12, 2018
@schmidt-sebastian schmidt-sebastian force-pushed the mrschmidt-bettererror branch 3 times, most recently from 751554f to 27b78a0 Compare November 12, 2018 22:05
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

LGTM with optional super minor nits.

dev/src/index.ts Outdated
ArrayElement: (name, value) =>
validateFieldValue(name, value, /* depth */ 0, /*inArray=*/true),
ArrayElement: (name, value) => validateFieldValue(
name, value, /* path */ undefined, /*level=*/0,

This comment was marked as spam.

This comment was marked as spam.

dev/src/index.ts Outdated
* @param options Validation options
* @param depth The current depth of the traversal.
* @param level The current depth of the traversal. This is used to decided

This comment was marked as spam.

This comment was marked as spam.

@@ -477,20 +481,29 @@ export class FieldPath extends Path<FieldPath> {
*/
static validateFieldPath(fieldPath: string|FieldPath) {
if (!(fieldPath instanceof FieldPath)) {
if (!is.string(fieldPath)) {
if (fieldPath === undefined) {

This comment was marked as spam.

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants