Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

sgress454
Copy link
Contributor

Adds information about the require_tld option to the isURL docs. Although present in the description of the options defaults, it's not listed among the other options so it's easy to miss that this helpful option exists (I did).

The options list here is a bit inconsistent as far as the "If set to true..." vs. "If set to false..." language; I opted for "If set to false" since the default is true. Happy to clean these all up to make them consistent if there's appetite for that, but I'm starting with a low-touch PR.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)

@WikiRik
Copy link
Member

WikiRik commented Mar 27, 2025

Thanks for the PR! I'll check what's wrong with the tests, that should not be due to your change

Copy link
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

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

I think we want to add this information in other places as well;

/*
options for isURL method
require_protocol - if set as true isURL will return false if protocol is not present in the URL
require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
protocols - valid protocols can be modified with this option
require_host - if set as false isURL will not check if host is present in the URL
require_port - if set as true isURL will check if port is present in the URL
allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
validate_length - if set as false isURL will skip string length validation
max_allowed_length will be ignored if this is set as false
max_allowed_length - if set isURL will not allow URLs longer than max_allowed_length
default is 2084 that IE maximum URL length
*/

**isFQDN(str [, options])** | check if the string is a fully qualified domain name (e.g. domain.com).<br/><br/>`options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false, allow_numeric_tld: false, allow_wildcard: false, ignore_max_length: false }`. If `allow_wildcard` is set to true, the validator will allow domain starting with `*.` (e.g. `*.example.com` or `*.shop.example.com`).

Could you add those as well?

Note that isEmail already has information about require_tld;

**isEmail(str [, options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, allow_underscores: false, domain_specific_validation: false, blacklisted_chars: '', host_blacklist: [] }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, email addresses without a TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by Gmail. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part. If `host_blacklist` is set to an array of strings or regexp, and the part of the email after the `@` symbol matches one of the strings defined in it, the validation fails. If `host_whitelist` is set to an array of strings or regexp, and the part of the email after the `@` symbol matches none of the strings defined in it, the validation fails.

@sgress454
Copy link
Contributor Author

@WikiRik updated!

@sgress454
Copy link
Contributor Author

Let me know when #2538 is in and I'll merge main again.

WikiRik
WikiRik previously approved these changes Mar 28, 2025
Copy link
Member

@WikiRik WikiRik left a comment

Choose a reason for hiding this comment

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

Nitpicky comments, but would be great if you could implement this as well

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/lib/isURL.js Outdated Show resolved Hide resolved
@sgress454
Copy link
Contributor Author

would be great if you could implement this as well

Sure thing!

@WikiRik
Copy link
Member

WikiRik commented Apr 8, 2025

@sgress454 we've updated the CI workflow file so I'm not allowed to update your branch. Could you do it yourself?

Copy link

codecov bot commented Apr 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (bdb8f9e) to head (5fcb23e).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2537   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2535      2535           
  Branches       641       641           
=========================================
  Hits          2535      2535           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sgress454
Copy link
Contributor Author

@WikiRik ✅ !

@WikiRik WikiRik requested a review from rubiin April 21, 2025 16:34
@rubiin rubiin merged commit d91af4b into validatorjs:master Apr 21, 2025
13 checks passed
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.