Skip to content
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

Remove "is-email" from testing suite #1247

Merged
merged 3 commits into from
Jun 22, 2024
Merged
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
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Examples

To run the examples locally, first run `npm install` in this directory. Then use node to run any of the examples like so: `node basic-validation.js`, `node composing-structs.js`, etc.
10 changes: 10 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "module",
"license": "MIT",
"dependencies": {
"is-email": "^1.0.2",
"is-url": "^1.2.4",
"is-uuid": "^1.0.2",
"superstruct": "latest"
}
}
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"is-email": "^1.0.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is-email is a package that validates an email. It requires using a custom type to use, and its only used when testing refiners. Removing this allows us to remove /@types.

"is-url": "^1.2.4",
"is-uuid": "^1.0.2",
"lodash": "^4.17.15",
"np": "^10.0.0",
"prettier": "^3.2.5",
Expand Down
3 changes: 0 additions & 3 deletions test/@types/is-email.d.ts

This file was deleted.

3 changes: 1 addition & 2 deletions test/validation/refine/invalid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import isEmail from 'is-email'
import { string, refine } from '../../../src'

export const Struct = refine(string(), 'email', isEmail)
export const Struct = refine(string(), 'email', (value) => value.includes('@'))

export const data = 'invalid'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example, I've simply made the test for a refiner check that there is an @ symbol in the data. Since we weren't testing whether it actually works with emails, this seems simpler and within the scope of this commit.


Expand Down
3 changes: 1 addition & 2 deletions test/validation/refine/valid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import isEmail from 'is-email'
import { string, refine } from '../../../src'

export const Struct = refine(string(), 'email', isEmail)
export const Struct = refine(string(), 'email', (value) => value.includes('@'))

export const data = 'name@example.com'

Expand Down