Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#66214 Feature/validator/is iso6391 by @TheMly
Browse files Browse the repository at this point in the history


* feat(@types/validator): include isISO6391 LanguageCodes declaration

* feat(@types/validator): include isISO6391 function declaration

* feat(@types/validator): Bump package version

---------

Co-authored-by: Manuel Lamy <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Dec 6, 2023
1 parent ccc24ed commit d798c56
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions types/validator/es/lib/isISO6391.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import isISO6391 from '../../lib/isISO6391';
export default isISO6391;
8 changes: 7 additions & 1 deletion types/validator/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for validator.js 13.7
// Type definitions for validator.js 13.9
// Project: https://github.com/validatorjs/validator.js
// Definitions by: tgfjt <https://github.com/tgfjt>
// Ilya Mochalov <https://github.com/chrootsu>
Expand All @@ -22,6 +22,7 @@ import * as _isFQDN from './lib/isFQDN';
import * as _isIBAN from './lib/isIBAN';
import * as _isISO31661Alpha2 from './lib/isISO31661Alpha2';
import * as _isISO4217 from './lib/isISO4217';
import * as _isISO6391 from './lib/isISO6391';
import * as _isURL from './lib/isURL';
import * as _isTaxID from './lib/isTaxID';

Expand Down Expand Up @@ -696,6 +697,11 @@ declare namespace validator {
*/
function isISO31661Alpha3(str: string): boolean;

/**
* Check if the string is a valid [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) officially assigned language code.
*/
const isISO6391: typeof _isISO6391.default;

interface IsISO8601Options {
/**
* If `strict` is `true`, performs additional checks for valid dates,
Expand Down
4 changes: 4 additions & 0 deletions types/validator/lib/isISO6391.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Check if the string is a valid [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) officially assigned language code.
*/
export default function isISO6391(str: string): boolean;
7 changes: 7 additions & 0 deletions types/validator/validator-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import isISO8601Func from 'validator/lib/isISO8601';
import isISO31661Alpha2Func from 'validator/lib/isISO31661Alpha2';
import isISO31661Alpha3Func from 'validator/lib/isISO31661Alpha3';
import isISO4217Func from 'validator/lib/isISO4217';
import isISO6391Func from 'validator/lib/isISO6391';
import isISRCFunc from 'validator/lib/isISRC';
import isIMEIFunc from 'validator/lib/isIMEI';
import isInFunc from 'validator/lib/isIn';
Expand Down Expand Up @@ -229,6 +230,9 @@ import isVatFunc from 'validator/lib/isVAT';
validator.isISO4217; // $ExpectType (str: string) => boolean
isISO4217Func; // $ExpectType (str: string) => boolean

validator.isISO6391; // $ExpectType (str: string) => boolean
isISO6391Func; // $ExpectType (str: string) => boolean

let _isISRC = validator.isISRC;
_isISRC = isISRCFunc;

Expand Down Expand Up @@ -410,6 +414,7 @@ import isISO8601FuncEs from 'validator/es/lib/isISO8601';
import isISO31661Alpha2FuncEs, { CountryCodes } from 'validator/es/lib/isISO31661Alpha2';
import isISO31661Alpha3FuncEs from 'validator/es/lib/isISO31661Alpha3';
import isISO4217FuncEs, { CurrencyCodes } from 'validator/es/lib/isISO4217';
import isISO6391FuncEs from 'validator/es/lib/isISO6391';
import isISRCFuncEs from 'validator/es/lib/isISRC';
import isInFuncEs from 'validator/es/lib/isIn';
import isIntFuncEs from 'validator/es/lib/isInt';
Expand Down Expand Up @@ -711,6 +716,8 @@ const any: any = null;
result = validator.isISO31661Alpha2('sample');
result = validator.isISO31661Alpha3('sample');

result = validator.isISO6391('sample');

result = validator.isISRC('sample');

result = validator.isIn('sample', []);
Expand Down

0 comments on commit d798c56

Please sign in to comment.