Skip to content

Commit 2c0ff53

Browse files
LiiaMenkebraaar
andauthored
feat(IsIBAN): Add IsIBANOptions as argument for IsIBAN decorator (#2618)
Co-authored-by: Brage Sekse Aarset <brage.aarset@gmail.com>
1 parent e0eaa02 commit 2c0ff53

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/decorator/string/IsIBAN.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import { ValidationOptions } from '../ValidationOptions';
22
import { buildMessage, ValidateBy } from '../common/ValidateBy';
3-
import isIBANValidator from 'validator/lib/isIBAN';
3+
import isIBANValidator, { IsIBANOptions } from 'validator/lib/isIBAN';
44

55
export const IS_IBAN = 'isIBAN';
66

77
/**
88
* Check if a string is a IBAN (International Bank Account Number).
99
* If given value is not a string, then it returns false.
1010
*/
11-
export function isIBAN(value: unknown): boolean {
12-
return typeof value === 'string' && isIBANValidator(value);
11+
export function isIBAN(value: unknown, options?: IsIBANOptions): boolean {
12+
return typeof value === 'string' && isIBANValidator(value, options);
1313
}
1414

1515
/**
1616
* Check if a string is a IBAN (International Bank Account Number).
1717
* If given value is not a string, then it returns false.
1818
*/
19-
export function IsIBAN(validationOptions?: ValidationOptions): PropertyDecorator {
19+
export function IsIBAN(options?: IsIBANOptions, validationOptions?: ValidationOptions): PropertyDecorator {
2020
return ValidateBy(
2121
{
2222
name: IS_IBAN,
2323
validator: {
24-
validate: (value, args): boolean => isIBAN(value),
24+
validate: (value, args): boolean => isIBAN(value, options),
2525
defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be an IBAN', validationOptions),
2626
},
2727
},

0 commit comments

Comments
 (0)