-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sync validatorjs version from v10.11.3 to v13.0.0
added new valdiators: `IsBase32`, `IsBIC`, `IsBtcAddress`, `IsDataURI`, `IsEAN`, `IsEthereumAddress`, `IsHSL`, `IsIBAN`, IsIdentityCard`, `IsISRC`, `IsLocale`, `IsMagnetURI`, `IsMimeType`, `IsOctal`, `IsPassportNumber`, `IsPostalCode`, `IsRFC3339`, `IsRgbColor`, `IsSemVer` BREAKING CHANGE: Validatorjs releases contain some breaking changes e.g. `IsMobileNumber` or `IsHexColor`. Please check validatorjs [CHANGELOG] Closes #576, #425
- Loading branch information
Showing
26 changed files
with
1,439 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ValidationOptions } from "../ValidationOptions"; | ||
import { buildMessage, ValidateBy } from "../common/ValidateBy"; | ||
import validator from "validator"; | ||
|
||
export const IS_BIC = "isBIC"; | ||
|
||
/** | ||
* Check if a string is a BIC (Bank Identification Code) or SWIFT code. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function isBIC(value: unknown): boolean { | ||
return typeof value === "string" && validator.isBIC(value); | ||
} | ||
|
||
/** | ||
* Check if a string is a BIC (Bank Identification Code) or SWIFT code. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function IsBIC(validationOptions?: ValidationOptions): PropertyDecorator { | ||
return ValidateBy( | ||
{ | ||
name: IS_BIC, | ||
validator: { | ||
validate: (value, args) => isBIC(value), | ||
defaultMessage: buildMessage( | ||
(eachPrefix) => eachPrefix + "$property must be a BIC or SWIFT code", | ||
validationOptions | ||
) | ||
} | ||
}, | ||
validationOptions | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ValidationOptions } from "../ValidationOptions"; | ||
import { buildMessage, ValidateBy } from "../common/ValidateBy"; | ||
import validator from "validator"; | ||
|
||
export const IS_BASE32 = "isBase32"; | ||
|
||
/** | ||
* Checks if a string is base32 encoded. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function isBase32(value: unknown): boolean { | ||
return typeof value === "string" && validator.isBase32(value); | ||
} | ||
|
||
/** | ||
* Check if a string is base32 encoded. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function IsBase32(validationOptions?: ValidationOptions): PropertyDecorator { | ||
return ValidateBy( | ||
{ | ||
name: IS_BASE32, | ||
validator: { | ||
validate: (value, args) => isBase32(value), | ||
defaultMessage: buildMessage( | ||
(eachPrefix) => eachPrefix + "$property must be base32 encoded", | ||
validationOptions | ||
) | ||
} | ||
}, | ||
validationOptions | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ValidationOptions } from "../ValidationOptions"; | ||
import { buildMessage, ValidateBy } from "../common/ValidateBy"; | ||
import validator from "validator"; | ||
|
||
export const IS_BTC_ADDRESS = "isBtcAddress"; | ||
|
||
/** | ||
* Check if the string is a valid BTC address. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function isBtcAddress(value: unknown): boolean { | ||
return typeof value === "string" && validator.isBtcAddress(value); | ||
} | ||
|
||
/** | ||
* Check if the string is a valid BTC address. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function IsBtcAddress(validationOptions?: ValidationOptions): PropertyDecorator { | ||
return ValidateBy( | ||
{ | ||
name: IS_BTC_ADDRESS, | ||
validator: { | ||
validate: (value, args) => isBtcAddress(value), | ||
defaultMessage: buildMessage( | ||
(eachPrefix) => eachPrefix + "$property must be a BTC address", | ||
validationOptions | ||
) | ||
} | ||
}, | ||
validationOptions | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ValidationOptions } from "../ValidationOptions"; | ||
import { buildMessage, ValidateBy } from "../common/ValidateBy"; | ||
import validator from "validator"; | ||
|
||
export const IS_DATA_URI = "isDataURI"; | ||
|
||
/** | ||
* Check if the string is a data uri format. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function isDataURI(value: unknown): boolean { | ||
return typeof value === "string" && validator.isDataURI(value); | ||
} | ||
|
||
/** | ||
* Check if the string is a data uri format. | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function IsDataURI(validationOptions?: ValidationOptions): PropertyDecorator { | ||
return ValidateBy( | ||
{ | ||
name: IS_DATA_URI, | ||
validator: { | ||
validate: (value, args) => isDataURI(value), | ||
defaultMessage: buildMessage( | ||
(eachPrefix) => eachPrefix + "$property must be a data uri format", | ||
validationOptions | ||
) | ||
} | ||
}, | ||
validationOptions | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { ValidationOptions } from "../ValidationOptions"; | ||
import { buildMessage, ValidateBy } from "../common/ValidateBy"; | ||
import validator from "validator"; | ||
|
||
export const IS_EAN = "isEAN"; | ||
|
||
/** | ||
* Check if the string is an EAN (European Article Number). | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function isEAN(value: unknown): boolean { | ||
return typeof value === "string" && validator.isEAN(value); | ||
} | ||
|
||
/** | ||
* Check if the string is an EAN (European Article Number). | ||
* If given value is not a string, then it returns false. | ||
*/ | ||
export function IsEAN(validationOptions?: ValidationOptions): PropertyDecorator { | ||
return ValidateBy( | ||
{ | ||
name: IS_EAN, | ||
validator: { | ||
validate: (value, args) => isEAN(value), | ||
defaultMessage: buildMessage( | ||
(eachPrefix) => eachPrefix + "$property must be an EAN (European Article Number)", | ||
validationOptions | ||
) | ||
} | ||
}, | ||
validationOptions | ||
); | ||
} |
Oops, something went wrong.