Skip to content

feat(validate): expand errors to include field name #242

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michaelfaith
Copy link
Collaborator

@michaelfaith michaelfaith commented May 18, 2025

PR Checklist

Overview

This change adds changes the errors array that's returned from validate to be an array of objects that includes field and message, so that each error message is associated with which field the error applies to.

errors is now of type ValidationError[] where ValidationError is

interface ValidationError {
  field: string;
  message: string;
}

Question: is there value in doing similar for warnings and recommendations? I'm thinking not, since the presence of those won't make the overall result invalid (whereas errors does result in an invalid result), but i'm certainly open to applying the same to those for consistency.

BREAKING CHANGE

This change adds changes the `errors` array that's returned from `validate` to be an array of objects that includes `field` and `message`, so that each error message is associated with which field the error applies to.

Question: is there value in doing similar for `warnings` and `recommendations`?  I'm thinking not, since the presence of those won't make the overall result invalid (whereas `errors` does result in an invalid result), but i'm certainly open to applying the same to those for consistency.

BREAKING CHANGE
@michaelfaith michaelfaith force-pushed the feat/field-info-with-errors branch from cc56111 to e032584 Compare May 18, 2025 19:39
@michaelfaith michaelfaith marked this pull request as ready for review May 18, 2025 19:48
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.

🚀 Feature: Option to get the valid fields returned?
1 participant