-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 03de4a7
Showing
82 changed files
with
10,780 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
./dist/* | ||
./dev/* | ||
./node_modules/* | ||
./flow-typed/* | ||
./docs | ||
webpack.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"plugins": ["jest"], | ||
"env": { | ||
"es6": true, | ||
"jest": true, | ||
"node": true | ||
}, | ||
"globals": { | ||
"VEST_VERSION": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:import/errors", | ||
"plugin:import/warnings" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 10, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"impliedStrict": true | ||
} | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4 | ||
], | ||
"no-console": 2, | ||
"no-multi-spaces": 1, | ||
"quotes": [ | ||
"error", | ||
"single" | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
], | ||
"eqeqeq": [ | ||
"error", | ||
"always" | ||
], | ||
"no-trailing-spaces": ["error", { "ignoreComments": true }], | ||
"no-implicit-globals": 2, | ||
"import/no-self-import": 2, | ||
"import/no-useless-path-segments": 2, | ||
"import/order": 2, | ||
"import/newline-after-import": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- | ||
Before creating a pull request, please read our contributing guidelines: | ||
CONTRIBUTING.md | ||
Remember: Unless it is an urgent bugfix, please use `next` as the base for your PR | ||
Please fill the following form (leave what's relevant) | ||
--> | ||
|
||
| Q | A | ||
| ---------------- | --- | ||
| Bug fix? | ✔/✖ | ||
| New feature? | ✔/✖ | ||
| Breaking change? | ✔/✖ | ||
| Deprecations? | ✔/✖ | ||
| Documentation? | ✔/✖ | ||
| Tests added? | ✔/✖ | ||
| Fixed issues | comma-separated list of issues fixed by the pull request, where applicable | ||
|
||
<!-- Describe your changes below in detail. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
node_modules | ||
.vscode | ||
.sass-cache | ||
dev_docpress | ||
_docpress | ||
dev | ||
version.json | ||
version.txt | ||
.version | ||
documentation/MAIN.md | ||
documentation/assets/**/*.css | ||
.DS_Store | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.vscode | ||
node_modules | ||
spec | ||
dev | ||
.babelrc | ||
.eslintignore | ||
.eslintrc | ||
.travis.yml | ||
webpack.config.js | ||
yarn.lock | ||
_docpress | ||
_docs | ||
flow-typed | ||
playground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
language: node_js | ||
cache: npm | ||
|
||
before_script: | ||
- npm run build | ||
- npm run eslint | ||
|
||
after_success: | ||
- chmod +x ./scripts/handle_changes.sh | ||
- source ./scripts/handle_changes.sh | ||
- node ./scripts/prep_docs.js | ||
- chmod +x ./scripts/push_tag_to_master.sh | ||
- if [ "$TRAVIS_BRANCH" = "release" ]; then ./scripts/push_tag_to_master.sh; fi | ||
- chmod +x ./scripts/prepare_next.sh | ||
- if [ "$TRAVIS_BRANCH" != "master" ]; then ./scripts/prepare_next.sh; fi | ||
|
||
deploy: | ||
- provider: npm | ||
email: $EMAIL_ADDRESS | ||
skip_cleanup: true | ||
api_key: $NPM_TOKEN | ||
on: | ||
repo: $TRAVIS_REPO_SLUG | ||
branch: master | ||
- provider: npm | ||
email: $EMAIL_ADDRESS | ||
skip_cleanup: true | ||
api_key: $NPM_TOKEN | ||
tag: "next" | ||
on: | ||
all_branches: true | ||
condition: $TRAVIS_BRANCH = "next" | ||
repo: $TRAVIS_REPO_SLUG | ||
- provider: npm | ||
email: $EMAIL_ADDRESS | ||
skip_cleanup: true | ||
api_key: $NPM_TOKEN | ||
tag: "DEVELOPMENT" | ||
on: | ||
all_branches: true | ||
condition: $TRAVIS_BRANCH != "next" && $TRAVIS_BRANCH != "master" && $TRAVIS_BRANCH != "release" | ||
repo: $TRAVIS_REPO_SLUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 ealush | ||
Copyright (c) 2017 Fiverr | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
![Vest](https://cdn.jsdelivr.net/gh/ealush/vest/docs/_assets/logo.png "Vest") | ||
|
||
# Vest - Validation Testing | ||
|
||
[![npm version](https://badge.fury.io/js/vest.svg)](https://badge.fury.io/js/vest) [![Build Status](https://travis-ci.org/ealush/vest.svg?branch=master)](https://travis-ci.org/ealush/vest) | ||
|
||
- [Documentation homepage](https://ealush.github.io/vest) | ||
- **Try vest live** | ||
- [Vanilla JS example](https://stackblitz.com/edit/vest-vanilla-support-example) | ||
- [ReactJS example](https://stackblitz.com/edit/vest-react-support-example) | ||
|
||
## What is Vest? | ||
Vest is a validations library for JS apps that derives its syntax from modern JS frameworks such as Mocha or Jest. It is easy to learn due to its use of already common declerative patterns. | ||
|
||
The idea behind Vest is that your validatios can be described as a 'spec' or a contract that reflects your form or feature structure. Your validations run in production, and they are framework agnostic - meaning Vest works well with React, Angular, Vue, or even without a framework at all. | ||
|
||
**Example code:** | ||
|
||
```js | ||
// validation.js | ||
import { validate, test, enforce } from 'vest'; | ||
|
||
const validation = (data) => validate('NewUserForm', () => { | ||
|
||
test('username', 'Must be at least 3 chars', () => { | ||
enforce(data.username).longerThanOrEquals(3); | ||
}); | ||
|
||
test('email', 'Is not a valid email address', () => { | ||
enforce(data.email) | ||
.isNotEmpty() | ||
.matches(/[^@]+@[^\.]+\..+/g); | ||
}); | ||
}); | ||
|
||
export default validation; | ||
``` | ||
|
||
```js | ||
// myFeature.js | ||
import validation from './validation.js'; | ||
|
||
const res = validation({ | ||
username: 'example', | ||
email: '[email protected]' | ||
}); | ||
|
||
res.hasErrors() // returns whether the form has errors | ||
res.hasErrors('username') // returns whether the 'username' field has errors | ||
res.getErrors() // returns an object with an array of errors per field | ||
res.getErrors('username') // returns an array of errors for the `username` field | ||
``` | ||
|
||
## Why Vest? | ||
- Vest is really easy to learn, and you can easily take your existing knowledge of unit tests and transfer it to validations. | ||
- Vest takes into account user interaction and warn only validations. | ||
- Your validations are structured, making it very easy to read and write. All validation files look the same. | ||
- Your validation logic is separate from your feature logic, preventing the spaghetti code that's usually involved with writing validations. | ||
- Validation logic is easy to share and reuse across features. | ||
- If your backend is node, you can use the same Vest modules for both client side and server side validations. | ||
|
||
|
||
__Vest is a continuation of [Passable](https://github.com/fiverr/passable) by Fiverr.__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require('@babel/register')({ | ||
configFile: './config/babel.config.js' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = (api) => { | ||
|
||
if (api) { | ||
api.cache(true); | ||
} | ||
|
||
const presets = [ | ||
'@babel/preset-env' | ||
]; | ||
|
||
const plugins = [ | ||
'babel-plugin-add-module-exports', | ||
'@babel/plugin-transform-object-assign' | ||
]; | ||
|
||
return { | ||
include: [/src/, /node_modules/], | ||
presets, | ||
plugins | ||
}; | ||
}; |
Oops, something went wrong.