https://github.com/one-com/one-validation
Regexp based validation collection for common internet validation tasks
https://github.com/one-com/one-validation
Last synced: 9 months ago
JSON representation
Regexp based validation collection for common internet validation tasks
- Host: GitHub
- URL: https://github.com/one-com/one-validation
- Owner: One-com
- Created: 2011-12-16T13:31:46.000Z (about 14 years ago)
- Default Branch: main
- Last Pushed: 2023-08-30T13:54:47.000Z (over 2 years ago)
- Last Synced: 2025-04-11T08:06:39.707Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 126 KB
- Stars: 36
- Watchers: 16
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# one-validation
[](http://badge.fury.io/js/one-validation)
[](https://travis-ci.org/One-com/one-validation)
[](https://coveralls.io/r/One-com/one-validation)
[](https://david-dm.org/One-com/one-validation)
This is a collection of regular expressions for general validation purposes.
The basic design concept is to split up the regexes into semantic parts of the pattern to match.
As an example a url consists of many parts like scheme, optional userinfo, subdomain, domain, toplevel domain, path, query and fragment.
It is a lot easier to write a maintainable and reusable regular expression by mathing each of these parts individually and write a regex that combines the individual later.
The library includes a TLD whitelist that can be updated using make.
This module works as a NodeJS CommonJS module, a require.js AMD module and falls back to exposing itself in the global scope on `one.validation` if included directly in the page.
Package managers:
* npm: `npm install one-validation`
* bower: `bower install validation`
## Supported patterns
* domain
* email
* url
## Examples
### domain and domainIdn
```
validation.domain.test('foo.co.uk');
return true;
```
```
validation.domainIdn.test('hällo-test.de');
return true;
```
### email and emailIdn
```
validation.email.test('test@foo.co.uk');
return true;
```
```
validation.domainIdn.test('test@hällo-test.de');
return true;
```
## Building
```
npm install
make
```