{"id":25882224,"url":"https://github.com/savory/validatte","last_synced_at":"2026-02-25T20:31:59.185Z","repository":{"id":58702580,"uuid":"529797096","full_name":"Savory/validatte","owner":"Savory","description":"A Savory Class validator for Deno","archived":false,"fork":false,"pushed_at":"2025-02-11T11:51:03.000Z","size":250,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-11T12:21:42.058Z","etag":null,"topics":["deno","hacktoberfest","typescript","validation","validator"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Savory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-28T07:49:28.000Z","updated_at":"2025-02-11T11:49:53.000Z","dependencies_parsed_at":"2025-02-11T12:21:33.829Z","dependency_job_id":"294812b9-c830-4f0e-b655-3a2d19f0263f","html_url":"https://github.com/Savory/validatte","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savory%2Fvalidatte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savory%2Fvalidatte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savory%2Fvalidatte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savory%2Fvalidatte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Savory","download_url":"https://codeload.github.com/Savory/validatte/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241533626,"owners_count":19977826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","hacktoberfest","typescript","validation","validator"],"created_at":"2025-03-02T15:57:49.728Z","updated_at":"2026-02-25T20:31:59.141Z","avatar_url":"https://github.com/Savory.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## A Savory class validator for Deno.\n\n![Made for Deno](https://img.shields.io/badge/made%20for-Deno-6B82F6?style=flat-square)\n[![CI](https://github.com/Savory/validatte/actions/workflows/run-tests.yml/badge.svg)](https://github.com/Savory/validatte/actions/workflows/run-tests.yml)\n[![codecov](https://codecov.io/gh/Savory/validatte/branch/main/graph/badge.svg?token=R6WXVC669Z)](https://codecov.io/gh/Savory/validatte)\n\n## Available decorators\n\n| Decorator                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **Type validation decorators**                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `IsBoolean()`                                        | Checks if a value is a boolean.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `IsString()`                                         | Checks if the string is a string.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| `IsNumber()`                                         | Checks if the value is a number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| `IsBigInt()`                                         | Checks if the value is a big int.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| `IsArray()`                                          | Checks if the value is an array                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `IsObject()`                                         | Checks if the value is an object                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| `IsSymbol()`                                         | Checks if the value is a Symbol                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `IsUndefined()`                                      | Checks if the value is undefined                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| `Contains(seed [, options])`                         | Check if the string contains the seed.\u003cbr/\u003e\u003cbr/\u003e `options` is an object which defaults to `{ ignoreCase: false }`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| `IsAfter(date? string)`                              | Check if the string is a date that's after the specified date (defaults to `now`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| `IsAlpha(locale?: string)`                           | Check if the string contains only alphabets depending on the locale.\u003cbr/\u003e\u003cbr/\u003eLocale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pl-Pl', 'pt-BR', 'pt-PT', 'ru-RU', 'sk-SK', 'sl-SI', 'sr-RS', 'sr-RSlatin', 'sv-SE', 'tr-TR', 'uk-UA']` and defaults to `en-US`.                                                                                                                                                                                                                    |\n| `IsAlphanumeric(locale?: string)`                    | Check if the string contains only alphabets and digits depending on the locale.\u003cbr/\u003e\u003cbr/\u003eLocale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pl-Pl', 'pt-BR', 'pt-PT', 'ru-RU', 'sk-SK', 'sl-SI', 'sr-RS', 'sr-RSlatin', 'sv-SE', 'tr-TR', 'uk-UA']` and defaults to `en-US`.                                                                                                                                                                                                         |\n| `IsAscii()`                                          | Check if the string contains ASCII chars only.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| `IsBase32()`                                         | Check if a string is base32 encoded.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| `IsBase64(options?: { urlSafe: boolean })`           | Check if a string is base64 encoded.\u003cbr/\u003e\u003cbr/\u003e `options` is an object which defaults to `{ urlSafe: false }`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n| `IsBefore(date?: string)`                            | Check if the string is a date that's before the specified date (defaults to `now`).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| `IsBIC()`                                            | Check if a string is a BIC (Bank Identification Code) or SWIFT code.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| `IsBoolean()`                                        | Check if a string is a boolean.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `IsBtcAddress()`                                     | Check if the string is a valid BTC address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| `ByteLength(options: { min: number, max: number? })` | Check if the string's length (in UTF-8 bytes) falls in a range.\u003cbr/\u003e\u003cbr/\u003e `options` is an object which defaults to `{ min: 0, max: undefined }`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| `IsCreditCard()`                                     | Check if the string is a valid Credit Card number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| `IsCurrency(option)`                                 | Check if the string is a valid currency amount.\u003cbr/\u003e\u003cbr/\u003e `options` is an object which defaults to `{ symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false }.`\u003cbr\u003e `Note`: The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range 1 to 3 will be given as [1, 2, 3].                                                                                                                                |\n| `IsDataURI()`                                        | Check if the string is in Data URI format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| `IsDate(format?: string)`                            | Check if the string is a valid date. Example `[2002-07-15, new Date()]`.\u003cbr/\u003e\u003cbr/\u003e `format` is a string that defaults to `YYYY/MM/DD`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| `IsDecimal(options? )`                               | Check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.\u003cbr/\u003e\u003cbr/\u003e `options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`\u003cbr/\u003e `locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'hu-HU', 'it-IT', 'ku-IQ', nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RSlatin', 'sv-SE', 'tr-TR', 'uk-UA']`.\u003cbr/\u003e **Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'. |\n| `IsHexadecimal()`                                    | Check if the string represents a hexadecimal number, such as 28E, AC7, etc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| `IsEmpty()`                                          | Check if a string is empty.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| `IsHexColor()`                                       | Check if the string represent a hex color.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| `IsIP()`                                             | Check if the string is a valid ip address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| `IsDivisibleBy(dividend: number)`                    | Check if the property is divisible by the given number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| `IsPort()`                                           | Check if the string is a valid port number (between 0 and 65535).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| `IsURL()`                                            | Check if the string is a valid URL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| **Number validation decorators**                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `GreaterOrEqual(num: number)`                        | Checks if the value is greater than or equal to the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| `Greater(num: number)`                               | Checks if the value is greater than the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n| `LowerOrEqual(num: number)`                          | Checks if the value is lower than or equal to the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n| `Lower(num: number)`                                 | Checks if the value is lower than the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| **String validation decorators**                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `LengthGreaterOrEqual(num: number)`                  | Checks if the length is greater than or equal to the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| `LengthGreater(num: number)`                         | Checks if the length is greater than the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| `LengthLowerOrEqual(num: number)`                    | Checks if the length is lower than or equal to the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n| `LengthLower(num: number)`                           | Checks if the length is lower than the specified number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n| `IsRegex(regex: RegExp)`                             | Checks if the string match the given RegExp.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| `IsEmail()`                                          | Checks if the string is an email.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| `IsFullWidth()`                                      | Checks if the string is a full-width string. Example ａ, ｂ, ｃ.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n| `IsPhoneNumber(country: string)`                     | Checks if the string is a local phone number for a country. Country must be ISO 3166 c.a.d 2 letter code. Example: FR, US, UK, DE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n| `IsHalfWidth()`                                      | Checks if the string is half-width string. Example: A, b, c.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n| `IsInternationalPhoneNumber()`                       | Checks if the string is an international phone number with extension and with or without leading 0. Example: +330XXXXXXXXX or +33XXXXXXXXX                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| `IsLowerCase()`                                      | Checks if the string is in lower case.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| `IsUpperCase()`                                      | Checks if the string is in uppercase.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |\n| **Object validation decorators**                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n| `Nested(class: Class)`                               | Checks if the property is a valid \"instance\" of Class. This means that all Validators of Class will be checked on the given object. The property can either be a plain object or a class instance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n\n## Usage\n\nCreate a Class using TypeScript Decorators and run `validateObject`.\n\nIf you need more built-in validators, please **open an issue** or **create merge request**\n\n```ts\nimport {\n\tcreateValidator,\n\tIsEmail, // this is a decorator (PascalCase)\n\tisEmail, // this is a check function, called behavior (camelCase)\n\tIsString,\n\tLengthLowerOrEqual,\n\tvalidateObject,\n} from 'https://deno.land/x/validatte/mod.ts';\n\n// Custom validator with custom error message containing argument. $constraint1 will be replaced by first argument. $constraint2 by second etc...\nconst IsWhiteListedEmailDomain = createValidator(\n\t(whiteListedDomain: string) =\u003e {\n\t\treturn (prop) =\u003e {\n\t\t\tif (isEmail(prop)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn prop.indexOf(`@${whiteListedDomain}`) !== -1;\n\t\t};\n\t},\n\t'Email shoud be from $constraint1 domain',\n);\n\nclass User {\n\t@IsString()\n\t@IsEmail()\n\t@IsWhiteListedEmailDomain('mydomain.com')\n\temail!: string;\n}\n\n// ---------- //\n\n// Valid\nconst user = new User();\nuser.email = 'myemailmydomain.com';\nconsole.log(validateObject(user, User));\n// []\n\n// ---------- //\n\n// Invalid\nconst failingUser = new User();\nfailingUser.email = 'wrongemail@email.com';\nconsole.log(validateObject(failingUser, User));\n\n/*\n[\n\t{\n\t\tproperty: 'email',\n\t\terrorMessage: `Email shoud be from mydomain.com domain`,\n\t\tconstraints: ['mydomain.com'],\n\t},\n];\n*/\n```\n\n## Come with us on this awesome journey\n\nWe always welcome contributors, feel free to submit a new feature or report a bug on our\n[Github Repository](https://github.com/Savory/validatte) and [join our discord](https://discord.gg/Q7ZHuDPgjA)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavory%2Fvalidatte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsavory%2Fvalidatte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavory%2Fvalidatte/lists"}