Skip to content

Commit

Permalink
Merge pull request #5 from jeffijoe/upgrade-deps
Browse files Browse the repository at this point in the history
Upgrade to MobX 6 and upgrade tooling
  • Loading branch information
jeffijoe committed Jun 16, 2022
2 parents cfa6a7d + a35b3d0 commit 5bc4b02
Show file tree
Hide file tree
Showing 25 changed files with 17,339 additions and 4,367 deletions.
23 changes: 15 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# Oh yeah!
language: node_js

# Add additional versions here as appropriate.
# Node 18 binaries require glibc >= 2.28
dist: focal

node_js:
- "stable"
- 'stable'
- '16'

# Lint errors should trigger a failure.
before_script: npm run lint
cache:
directories:
- node_modules

# Runs the coverage script (which runs the tests)
script: npm run cover
# Set INIT_CWD for Husky due to Npm 7 not including it.
before_install:
- export INIT_CWD="$(pwd)"

# Lint errors should trigger a failure.
before_script: npm run lint && npm run build

# Code coverage
after_success: npm run coveralls
script: npm run coveralls
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.0-alpha.2

* Upgraded to MobX 6
* Removed `peerDependencies` in favor of BYOM (Bring Your Own MobX)
* Overhaul build, lint and test infra

## 1.0.0

* Upgraded to MobX v4, breaks compatibility with MobX <= 3
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Validation library for [MobX](https://github.com/mobxjs/mobx).
## Install

```
npm install --save validx
# Bring your own MobX
npm install --save mobx validx
```

Table of Contents
Expand Down
12 changes: 6 additions & 6 deletions examples/babel/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ const validation = validationContext(obj, {
name: [required({ msg: 'Name is required' })],
email: [
required('Email is required'), // shorthand message parameter for the required validator.
pattern({ pattern: 'email', msg: 'That is not a valid email' })
pattern({ pattern: 'email', msg: 'That is not a valid email' }),
],
age: [
required('Age is required'),
pattern({
pattern: /\d/, // regex pattern for numbers
msg: 'Age must be a number'
msg: 'Age must be a number',
}),
// And a custom validator.
opts => {
(opts) => {
// Validators return either true for success, and false (for the default error message)
// or a string (for a custom error message)
return opts.value >= 13 || 'You must be over 13 years of age to sign up.'
}
]
},
],
})

// Let's set up an autorun that will log whenever
Expand All @@ -38,7 +38,7 @@ autorun(() => {
console.log('')
console.log('-------- Validation Summary ---------')
console.log('Bad field count: ', Object.keys(validation.errors).length)
Object.keys(validation.errors).map(key => {
Object.keys(validation.errors).map((key) => {
// errors[key] is an observable array.
// using slice to print them nicely in the console.
console.log(
Expand Down
14 changes: 7 additions & 7 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
validationContext,
required,
pattern,
IValidatorOptions
} from '../../../lib'
IValidatorOptions,
} from '../../../src'
import { action, autorun } from 'mobx'
import { inspect } from 'util'

Expand All @@ -23,21 +23,21 @@ const validation = validationContext(obj, {
name: [required({ msg: 'Name is required' })],
email: [
required('Email is required'), // shorthand message parameter for the required validator.
pattern({ pattern: 'email', msg: 'That is not a valid email' })
pattern({ pattern: 'email', msg: 'That is not a valid email' }),
],
age: [
required('Age is required'),
pattern({
pattern: /\d/, // regex pattern for numbers
msg: 'Age must be a number'
msg: 'Age must be a number',
}),
// And a custom validator.
(opts: IValidatorOptions<IObj>) => {
// Validators return either true for success, and false (for the default error message)
// or a string (for a custom error message)
return opts.value >= 13 || 'You must be over 13 years of age to sign up.'
}
]
},
],
})

// Let's set up an autorun that will log whenever
Expand All @@ -49,7 +49,7 @@ autorun(() => {
console.log('')
console.log('-------- Validation Summary ---------')
console.log('Bad field count: ', Object.keys(validation.errors).length)
Object.keys(validation.errors).map(key => {
Object.keys(validation.errors).map((key) => {
// errors[key] is an observable array.
// using slice to print them nicely in the console.
console.log(
Expand Down

0 comments on commit 5bc4b02

Please sign in to comment.