Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 48 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,58 @@ on:
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
name: Build on Node.js 22
steps:
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Lint
run: npm run lint
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
index.js
lib/
es/
validator.js
validator.min.js
retention-days: 1

test:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22, 20, 18, 16, 14, 12, 10, 8]
name: Run tests on Node.js ${{ matrix.node-version }}
steps:
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Run tests
run: npm test
- if: matrix.node-version == 22
name: Send coverage info to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test:ci
- if: matrix.node-version == 22
name: Send coverage info to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: npm install --legacy-peer-deps
run: npm install
- name: Run Tests
run: npm test
- name: Publish Package to NPM Registry
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In general, we follow the "fork-and-pull" Git workflow.
1. [Fork](https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project) the repository on GitHub
2. Clone the project to your local machine
3. Work on your fork
* Install the project using `npm install --legacy-peer-deps` (see [issue](https://github.com/validatorjs/validator.js/issues/2123))
* Install the project using `npm install`
* Make your changes and additions
- Most of your changes should be focused on src/ and test/ folders and/or [README.md](https://github.com/validatorjs/validator.js/blob/master/README.md).
- Files such as validator.js, validator.min.js and files in lib/ folder are autogenerated when running tests (npm test) and need not to be changed **manually**.
Expand Down
32 changes: 0 additions & 32 deletions build-browser.js

This file was deleted.

39 changes: 39 additions & 0 deletions build-browser.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint import/no-extraneous-dependencies: 0 */
import fs from 'fs';
import { rollup } from 'rollup';
import { babel } from '@rollup/plugin-babel';
import babelPresetEnv from '@babel/preset-env';
import pkg from "./package.json" with { type: "json" };

rollup({
input: 'src/index.js',
plugins: [
babel({
presets: [[babelPresetEnv, {
modules: false,
targets: {
node: '0.10',
ie: '11'
}
}]],
babelHelpers: 'bundled',
babelrc: false,
}),
],
})
.then((bundle) =>
bundle.write({
file: 'validator.js',
format: 'umd',
name: pkg.name,
banner: `/*!\n${String(fs.readFileSync('./LICENSE'))
.trim()
.split('\n')
.map((l) => ` * ${l}`)
.join('\n')}\n */`,
})
)
.catch((e) => {
process.stderr.write(`${e.message}\n`);
process.exit(1);
});
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
"url": "git+https://github.com/validatorjs/validator.js.git"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/cli": "^7.28.3",
"@babel/core": "^7.28.5",
"@babel/preset-env": "^7.28.5",
"@babel/register": "^7.28.3",
"@rollup/plugin-babel": "^6.1.0",
"babel-eslint": "^10.0.1",
"babel-plugin-add-module-exports": "^1.0.0",
"eslint": "^4.19.1",
Expand All @@ -49,8 +50,7 @@
"npm-run-all": "^4.1.5",
"nyc": "^14.1.0",
"rimraf": "^3.0.0",
"rollup": "^0.47.0",
"rollup-plugin-babel": "^4.0.1",
"rollup": "^4.53.2",
"timezone-mock": "^1.3.6",
"uglify-js": "^3.0.19"
},
Expand All @@ -62,12 +62,13 @@
"clean:browser": "rimraf validator*.js",
"clean": "run-p clean:*",
"minify": "uglifyjs validator.js -o validator.min.js --compress --mangle --comments /Copyright/",
"build:browser": "node --require @babel/register build-browser && npm run minify",
"build:browser": "node build-browser.mjs && npm run minify",
"build:es": "babel src -d es --env-name=es",
"build:node": "babel src -d .",
"build": "run-p build:*",
"pretest": "npm run build && npm run lint",
"test": "nyc --reporter=cobertura --reporter=text-summary mocha --require @babel/register --reporter dot --recursive"
"test": "npm run test:ci",
"test:ci": "nyc --reporter=cobertura --reporter=text-summary mocha --require @babel/register --reporter dot --recursive"
},
"engines": {
"node": ">= 0.10"
Expand Down