Skip to content

feat: add ata-validator resolver#845

Open
armagandalkiran wants to merge 3 commits intoreact-hook-form:masterfrom
armagandalkiran:feat/ata-validator-resolver
Open

feat: add ata-validator resolver#845
armagandalkiran wants to merge 3 commits intoreact-hook-form:masterfrom
armagandalkiran:feat/ata-validator-resolver

Conversation

@armagandalkiran
Copy link
Copy Markdown

Summary

This PR adds a new resolver for ata-validator, an ultra-fast JSON Schema validator for Node.js.

What is ata-validator?

ata-validator is a high-performance JSON Schema validation library that compiles schemas into optimized JavaScript code at runtime. It supports JSON Schema draft 2020-12, provides AJV-compatible error format (keyword, instancePath, schemaPath, params, message), and offers features like coerceTypes and removeAdditional out of the box.

What is included

  • ataResolver — the resolver function that integrates ata-validator with react-hook-form
  • parseErrorSchema — maps ata-validator errors (JSON Pointer instancePath) to react-hook-form field paths (dot notation)
  • Support for criteriaMode: "all" via appendErrors
  • Support for shouldUseNativeValidation via validateFieldsNatively
  • resolverOptions.raw for returning unmodified input values on valid data
  • schemaOptions passthrough for ata-validator options (coerceTypes, removeAdditional, allErrors, etc.)

Files added/changed

File Description
ata-validator/package.json Subpackage metadata and peer dependencies
ata-validator/src/ata-validator.ts Resolver implementation
ata-validator/src/types.ts TypeScript type definitions
ata-validator/src/index.ts Public exports
ata-validator/src/__tests__/ata-validator.ts Unit tests (8 test cases)
ata-validator/src/__tests__/Form.tsx Integration test with a React form
ata-validator/src/__tests__/Form-native-validation.tsx Native browser validation test
ata-validator/src/__tests__/__fixtures__/data.ts Test schemas, valid/invalid data, field refs
package.json Added exports, build script, devDependency, keyword
bun.lock Updated lockfile

Checklist

  • bun install — installs successfully
  • bun test — all 8 tests pass
  • bun lint — no lint errors
  • bun run build:ata-validator — builds successfully
  • Pre-commit hooks (lefthook: lint + typescript) pass

This is my first contribution to this project. If there is anything that needs adjustment — naming conventions, test patterns, structure, or anything else — I am happy to make changes. Please do not hesitate to point out anything that should be different.

Add a new resolver for ata-validator, an ultra-fast JSON Schema
validator for Node.js.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new ataResolver package to integrate the ata-validator JSON Schema validator into the @hookform/resolvers monorepo, including exports/build wiring and a test suite to validate error mapping and native validation behavior.

Changes:

  • Introduces ata-validator subpackage with resolver implementation, types, and public exports.
  • Adds unit + React integration tests (including native browser validation) plus fixtures/snapshots.
  • Updates root package.json exports/build scripts/files list and lockfile to include ata-validator.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
package.json Adds export map entry, build script, files list, keywords, and devDependency for ata-validator.
bun.lock Locks ata-validator and related dependencies.
ata-validator/package.json Defines the new subpackage metadata and peer dependencies.
ata-validator/src/types.ts Adds resolver and error type definitions for the subpackage.
ata-validator/src/index.ts Exposes the resolver + types as the public entrypoint.
ata-validator/src/ata-validator.ts Implements ataResolver and error-to-RHF mapping logic.
ata-validator/src/__tests__/ata-validator.ts Unit tests covering success, raw mode, criteriaMode=all, required/undefined, and options.
ata-validator/src/__tests__/Form.tsx React integration test validating RHF error rendering.
ata-validator/src/__tests__/Form-native-validation.tsx Integration test for shouldUseNativeValidation.
ata-validator/src/__tests__/__fixtures__/data.ts Shared schemas/data/field refs for tests.
ata-validator/src/__tests__/__snapshots__/ata-validator.ts.snap Snapshots for resolver error outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Avoid recompiling the schema on every validation call by constructing
the Validator once when the resolver is created instead of on each
form submit.
@armagandalkiran
Copy link
Copy Markdown
Author

@bluebill1049 Hey!, thank you for your support could you please check again?

@armagandalkiran
Copy link
Copy Markdown
Author

@bluebill1049 Thanks again, is there anything left that should i do?

Copy link
Copy Markdown
Member

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

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

LGTM

@bluebill1049
Copy link
Copy Markdown
Member

thanks @armagandalkiran i will merge after fix the publish action.

@mertcanaltin
Copy link
Copy Markdown

Thanks for work, @armagandalkiran!

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.

4 participants