Skip to content

feat(isSIP): check if string is a SIP - #2458

Open
aabdullaharif wants to merge 3 commits into
validatorjs:masterfrom
aabdullaharif:master
Open

feat(isSIP): check if string is a SIP#2458
aabdullaharif wants to merge 3 commits into
validatorjs:masterfrom
aabdullaharif:master

Conversation

@aabdullaharif

Copy link
Copy Markdown

Description

This pull request addresses issue #2436 by implementing SIP URI validation in the library.

Changes Made

  • Added a new validation function for SIP URIs.
  • Included comprehensive test cases to verify the functionality of the validation.
  • Updated the documentation to reflect the new feature.

Checklist

  • [✔] PR contains only changes related; no stray files, etc.
  • [✔] README updated (where applicable)
  • [✔] Tests written (where applicable)
  • [✔] References provided in PR (where applicable)

rubiin
rubiin previously approved these changes Sep 29, 2024
Comment thread src/lib/isSIP.js Outdated
Comment thread src/lib/isSIP.js Outdated
@rubiin
rubiin requested a review from pano9000 September 30, 2024 10:23
Comment thread README.md
**isVAT(str, countryCode)** | check if the string is a [valid VAT number][VAT Number] if validation is available for the given country code matching [ISO 3166-1 alpha-2][ISO 3166-1 alpha-2]. <br/><br/>`countryCode` is one of `['AL', 'AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'EL', 'ES', 'FI', 'FR', 'GB', 'GT', 'HN', 'HR', 'HU', 'ID', 'IE', 'IL', 'IN', 'IS', 'IT', 'KZ', 'LT', 'LU', 'LV', 'MK', 'MT', 'MX', 'NG', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'RO', 'RS', 'RU', 'SA', 'SE', 'SI', 'SK', 'SM', 'SV', 'TR', 'UA', 'UY', 'UZ', 'VE']`.
**isWhitelisted(str, chars)** | check if the string consists only of characters that appear in the whitelist `chars`.
**matches(str, pattern [, modifiers])** | check if the string matches the pattern.<br/><br/>Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`.
**isSIP(str)** | check if the string is a [SIP](https://www.ietf.org/rfc/rfc3261.txt).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please put this in the correct alphabetical place (after isSemVer)

Comment thread src/lib/isSIP.js

/* Regular expression to match the SIP URI structure */
function isValidSipUri(uri) {
const sipUriRegex = /^sips?:([^:@]+(:[^@]*)?@)?((([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}|(\d{1,3}\.){3}\d{1,3}|\[[0-9a-fA-F:]+\])(:\d{1,5})?)(;([a-zA-Z0-9-]+=[^;?]+|lr))*?(\?[^#]*)?$/;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have a reference for this Regex? Are there sources for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants