Thank you for your interest in contributing to expressjs-field-validator! This guide will help you get started, whether you're fixing a bug, adding a new validation rule, improving documentation, or anything in between.
- Code of Conduct
- Getting Started
- Project Structure
- Development Workflow
- Making Changes
- Coding Guidelines
- Testing
- Submitting a Pull Request
- Reporting Issues
Please be respectful and constructive in all interactions. We welcome contributors of all experience levels and backgrounds. Harassment, discrimination, or hostile behaviour of any kind will not be tolerated.
-
Fork the repository on GitHub.
-
Clone your fork locally:
git clone https://github.com/<your-username>/expressjs-field-validator.git cd expressjs-field-validator
-
Add the upstream remote so you can sync future changes:
git remote add upstream https://github.com/gsmithun4/expressjs-field-validator.git
-
Install dependencies:
npm install
expressjs-field-validator/
├── .github/workflows/ # CI/CD GitHub Actions workflows
├── assets/ # Screenshots and static assets
├── config-builder/ # Visual config builder tool source
├── example/ # Example Express.js application
├── lib/ # Core library source code
├── index.js # Main entry point
├── index.d.ts # TypeScript type definitions
├── index.example.js # Usage examples
├── .eslintrc.js # ESLint configuration
└── package.json
Key files to be aware of:
lib/— This is where the validation logic lives. Most bug fixes and new features will touch files here.index.js— The public API surface. New exports must be added here.index.d.ts— TypeScript definitions. Any new public API must be reflected here.
-
Sync your fork with the latest upstream changes before starting work:
git fetch upstream git checkout master git merge upstream/master
-
Create a descriptive feature branch:
git checkout -b feat/add-my-new-validator # or git checkout -b fix/fix-date-validation-bug -
Make your changes (see Making Changes below).
-
Lint your code:
npm run lint
-
Run the tests to make sure nothing is broken:
npm test -
Commit your changes following the commit message guidelines.
-
Push your branch and open a Pull Request.
- Identify the relevant file(s) in
lib/. - Add a test case that reproduces the bug before fixing it, so the test starts failing and then passes after your fix.
- Keep the fix minimal and focused — avoid unrelated refactoring in the same PR.
New rules (e.g., isIPAddress(), isCreditCard()) should follow the existing fluent-API pattern:
- Add the rule method to the appropriate file in
lib/. - Ensure the method is chainable (returns
this). - Add the corresponding error message/debug message.
- Export it if necessary via
index.js. - Add the TypeScript definition in
index.d.ts. - Write tests covering:
- Valid input passes
- Invalid input fails with the correct error message
- Edge cases (empty string,
null,undefined)
- Update
README.mdwith a description of the new rule under the Available Options section.
For larger features (e.g., new middleware types, new doc-generation options):
- Open an issue first to discuss the design before writing code. This avoids wasted effort if the direction needs adjustment.
- Follow the same patterns established in existing code.
- Add appropriate tests.
- Update all relevant documentation:
README.md,index.d.ts, and any example files.
Documentation improvements are always welcome! This includes:
- Fixing typos or unclear wording in
README.md - Adding missing examples
- Improving TypeScript types
- Updating the
example/application
For doc-only changes, a full test run is not required, but please still lint before submitting.
- Style: The project uses ESLint (see
.eslintrc.js). Runnpm run lintbefore committing. Do not disable lint rules without discussion. - No new dependencies: This package prides itself on having zero runtime dependencies. Do not add external packages to
dependenciesinpackage.json. Dev dependencies for testing/tooling are acceptable. - Chainable API: All field-definition methods must return
thisto preserve the fluent chain. - Backward compatibility: Avoid breaking changes to the public API. If a breaking change is necessary, it must be discussed in an issue first and documented in the migration guide.
- TypeScript types: All public API additions must have corresponding type definitions in
index.d.ts.
Use clear, conventional commit messages:
feat: add isIPAddress() validation rule
fix: correct date parsing for DD/MM/YYYY format
docs: add example for nested object validation
chore: update ESLint config
test: add edge cases for isMatching()
All new code must be accompanied by tests. Please ensure:
- Tests cover the happy path, error cases, and boundary/edge cases.
- Existing tests continue to pass — do not delete or modify tests to make them pass unless the behaviour was intentionally changed.
Run tests with:
npm testFor coverage reporting (if configured):
npm run test:coverageCode quality is also tracked via SonarCloud. Aim to keep code smells, duplication, and coverage metrics in a healthy state.
-
Ensure your branch is up to date with
upstream/master. -
Make sure
npm run lintandnpm testboth pass. -
Push your branch to your fork:
git push origin feat/my-feature
-
Open a Pull Request against the
masterbranch of the upstream repo. -
Fill in the PR description with:
- What the change does
- Why it is needed (link to the related issue if applicable)
- How to test it
- Any migration notes for breaking changes
-
A maintainer will review your PR. Please respond to any feedback promptly and make requested changes in additional commits (squashing can happen at merge time).
Found a bug or have a feature request? Please open an issue and include:
- For bugs: Node.js version, package version, a minimal reproducible code snippet, and the expected vs actual behaviour.
- For feature requests: A clear description of the use case and why the existing API doesn't cover it.
Thank you for helping make expressjs-field-validator better! 🎉