https://github.com/confuser/validity-url-optional-tlds
Validity style validator which extends url to allow for non-tld urls
https://github.com/confuser/validity-url-optional-tlds
Last synced: 9 months ago
JSON representation
Validity style validator which extends url to allow for non-tld urls
- Host: GitHub
- URL: https://github.com/confuser/validity-url-optional-tlds
- Owner: confuser
- License: bsd-3-clause
- Created: 2013-11-04T14:12:17.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-11-07T18:04:14.000Z (over 12 years ago)
- Last Synced: 2025-09-12T04:40:45.043Z (9 months ago)
- Language: JavaScript
- Size: 177 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# validity-url-optional-tlds
[](https://travis-ci.org/confuser/validity-url-optional-tlds)
Validity style validator which extends url to allow for non-tld urls.
## Installation
npm install validity-url-optional-tlds
## Usage
Below is a simple example for usage with schemata:
```js
var validity = require('validity')
, schemata = require('schemata')
, save = require('save')
, createUrlValidator = require('validity-url-optional-tlds')
var schema = schemata(
{ url:
{ type: String
, validators: { all: [ createUrlValidator() ] }
}
})
```
## API
### var validate = createUrlValidator()
Create a validate function.
### validate(String:key, String:keyDisplayName, Object:object, Function:cb)
This is a validity compatible function, which in turn is used by schemata for
schema validation.
The callback signature cb(err, errorMessage).
err is an Error object if something bad happened and null otherwise.
errorMessage is a String if a validation error happened and undefined otherwise.
## Licence
Licensed under the [New BSD License](http://opensource.org/licenses/bsd-license.php)