Skip to content

Improve Error Handling and Messages #7

@abmercy035

Description

@abmercy035

Enhance the error handling system to provide more detailed, customizable, and user-friendly error messages.

Problem to Solve:
Current error messages are basic and not always helpful for end-users. We need more context-aware and customizable error reporting.

Acceptance Criteria:

  • Implement hierarchical error objects with field paths
  • Support for internationalization (i18n) of error messages
  • Add more context to error messages (e.g., include the actual and expected values)
  • Support for custom error message templates
  • Add error codes for programmatic error handling
  • Improve error aggregation for multiple validation failures
  • Add tests for all error handling scenarios

Implementation Suggestions:

  • Create an ErrorMessage class with formatting options
  • Add support for error message templates with variable substitution
  • Implement a more structured error result format (object instead of string)

Example Usage:

const errors = Validata(rules, data, {
  errorFormat: 'detailed', // 'simple', 'detailed', 'object'
  language: 'en',
  customMessages: {
    'string.min': '{field} must have at least {min} characters',
    'email.invalid': '{field} is not a valid email address'
  }
});

Labels: enhancement, error-handling, user-experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions