Skip to content

Commit

Permalink
Hello, World.
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Dec 23, 2019
0 parents commit 301345a
Show file tree
Hide file tree
Showing 81 changed files with 10,738 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
./dist/*
./dev/*
./node_modules/*
./flow-typed/*
./docs
webpack.config.js
49 changes: 49 additions & 0 deletions .eslintrc
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
}
}
21 changes: 21 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
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. -->
13 changes: 13 additions & 0 deletions .gitignore
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
14 changes: 14 additions & 0 deletions .npmignore
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
5 changes: 5 additions & 0 deletions CHANGELOG.md
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).
22 changes: 22 additions & 0 deletions LICENSE
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.
63 changes: 63 additions & 0 deletions README.md
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 declarative patterns.

The idea behind Vest is that your validations 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@example.com'
});

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.__
3 changes: 3 additions & 0 deletions config/babel-register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('@babel/register')({
configFile: './config/babel.config.js'
});
21 changes: 21 additions & 0 deletions config/babel.config.js
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
};
};
Loading

0 comments on commit 301345a

Please sign in to comment.