Skip to content
Merged

Dev #39

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
/build
*.tsbuildinfo

# environment variables
.env
Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"tslib": "^2.8.1"
},
"devDependencies": {
"@panates/eslint-config": "^2.1.1",
"@panates/eslint-config-ts": "^2.1.1",
"@panates/tsconfig": "^2.1.1",
"@panates/eslint-config": "^2.1.3",
"@panates/eslint-config-ts": "^2.1.3",
"@panates/tsconfig": "^2.1.3",
"@swc-node/register": "^1.11.1",
"@swc/core": "^1.15.24",
"@swc/helpers": "^0.5.21",
Expand Down
6 changes: 4 additions & 2 deletions src/rules/format-rules/is-base64.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsBase64Options as _IsBase64Options,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
Expand All @@ -7,7 +9,7 @@ import {
} from '../../core/index.js';

export interface Base64ValidatorOptions
extends ValidationOptions, validatorJS.IsBase64Options {}
extends ValidationOptions, _IsBase64Options {}

/**
* Validates if value is a "Base64" string.
Expand Down
6 changes: 4 additions & 2 deletions src/rules/format-rules/is-credit-card.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsCreditCardOptions as _IsCreditCardOptions,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
Expand All @@ -7,7 +9,7 @@ import {
} from '../../core/index.js';

export interface CreditCardValidatorOptions
extends ValidationOptions, validatorJS.IsCreditCardOptions {}
extends ValidationOptions, _IsCreditCardOptions {}

/**
* Validates if value is a credit card number
Expand Down
6 changes: 4 additions & 2 deletions src/rules/format-rules/is-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsEmailOptions as _IsEmailOptions,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
Expand Down Expand Up @@ -76,7 +78,7 @@ export interface IsEmailOptions extends ValidationOptions {
* @validator isEmail
*/
export function isEmail(options?: IsEmailOptions) {
const emailOptions: validatorJS.IsEmailOptions = {
const emailOptions: _IsEmailOptions = {
allow_display_name: true,
allow_utf8_local_part: options?.utf8LocalPart,
ignore_max_length: true,
Expand Down
6 changes: 4 additions & 2 deletions src/rules/format-rules/is-fqdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsFQDNOptions as _IsFQDNOptions,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
Expand All @@ -19,7 +21,7 @@ export interface IsFQDNOptions extends ValidationOptions {
* @validator isFQDN
*/
export function isFQDN(options?: IsFQDNOptions) {
const opts: validatorJS.IsFQDNOptions = {
const opts: _IsFQDNOptions = {
allow_wildcard: options?.allowWildcard,
};
return validator<string, string>(
Expand Down
6 changes: 4 additions & 2 deletions src/rules/format-rules/is-hash.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type HashAlgorithm as _HashAlgorithm,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
type ValidationOptions,
validator,
} from '../../core/index.js';

export type HashAlgorithm = validatorJS.HashAlgorithm;
export type HashAlgorithm = _HashAlgorithm;

/**
* Validates if value a hash of type algorithm
Expand Down
6 changes: 4 additions & 2 deletions src/rules/format-rules/is-issn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsISSNOptions as _IsISSNOptions,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
Expand All @@ -20,7 +22,7 @@ export interface IsISSNOptions extends ValidationOptions {
* @validator isISSN
*/
export function isISSN(options?: IsISSNOptions) {
const opts: validatorJS.IsISSNOptions = {
const opts: _IsISSNOptions = {
case_sensitive: options?.caseSensitive,
};
return validator<string, string>(
Expand Down
6 changes: 4 additions & 2 deletions src/rules/format-rules/is-mac-address.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsMACAddressOptions as _IsMACAddressOptions,
} from '@browsery/validator';
import { type Nullish } from 'ts-gems';
import {
type Context,
Expand Down Expand Up @@ -28,7 +30,7 @@ export interface IsMACAddressOptions extends ValidationOptions {
* @validator isMACAddress
*/
export function isMACAddress(options?: IsMACAddressOptions) {
const opts: validatorJS.IsMACAddressOptions = {
const opts: _IsMACAddressOptions = {
no_separators: options?.noSeparators,
eui: options?.eui,
};
Expand Down
12 changes: 6 additions & 6 deletions src/rules/format-rules/is-mobile-phone.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsMobilePhoneOptions as _IsMobilePhoneOptions,
type MobilePhoneLocale as _MobilePhoneLocale,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
Expand All @@ -18,18 +21,15 @@ export interface IsMobilePhoneOptions extends ValidationOptions {
* Locale or locales of the mobile phone
* @default 'any'
*/
locale?:
| 'any'
| validatorJS.MobilePhoneLocale
| validatorJS.MobilePhoneLocale[];
locale?: 'any' | _MobilePhoneLocale | _MobilePhoneLocale[];
}

/**
* Validates if value is a valid Email
* @validator isMobilePhone
*/
export function isMobilePhone(options?: IsMobilePhoneOptions) {
const opts: validatorJS.IsMobilePhoneOptions = {
const opts: _IsMobilePhoneOptions = {
strictMode: options?.strictMode,
};
return validator<string, string>(
Expand Down
7 changes: 4 additions & 3 deletions src/rules/format-rules/is-url.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type IsURLOptions as _IsURLOptions,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
type ValidationOptions,
validator,
} from '../../core/index.js';

export interface IsURLOptions
extends ValidationOptions, validatorJS.IsURLOptions {}
export interface IsURLOptions extends ValidationOptions, _IsURLOptions {}

/**
* Validates if value is an URL
Expand Down
6 changes: 5 additions & 1 deletion src/rules/format-rules/is-uuid.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import validatorJS, { UUIDVersion } from '@browsery/validator';
import validatorJS, {
type UUIDVersion as _UUIDVersion,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
type ValidationOptions,
validator,
} from '../../core/index.js';

export type UUIDVersion = _UUIDVersion;

/**
* Validates if value is a "UUID".
* @validator isUUID
Expand Down
13 changes: 10 additions & 3 deletions src/rules/format-rules/is-vat-number.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import validatorJS from '@browsery/validator';
import validatorJS, {
type VATCountryCode as _VATCountryCode,
} from '@browsery/validator';
import type { Nullish } from 'ts-gems';
import {
type Context,
type ValidationOptions,
validator,
} from '../../core/index.js';

export type VATCountryCode = _VATCountryCode;

/**
* Validates if value is an VAT number
* Validates if value is a VAT number
* @validator isVAT
*/
export function isVATNumber(countryCode: string, options?: ValidationOptions) {
export function isVATNumber(
countryCode: VATCountryCode,
options?: ValidationOptions,
) {
return validator<string, string>(
'isVATNumber',
(input: unknown, context: Context, _this): Nullish<string> => {
Expand Down
6 changes: 2 additions & 4 deletions tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"extends": ["./tsconfig-base.json", "@panates/tsconfig/build.json"],
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": true,
"outDir": "build",
"rootDir": "src",
"outDir": "build"
},
"include": ["src"]
}