uvalidaiton
javascript validation library for different runtimes
Features
Imagine such data structure
Or it's another view
const a = {
b: {
e: null
},
c: {
f: null,
g: null,
},
d: {
h: {
i: null
}
},
}
As the author I have had some requirements which this library should cover:
- Validity of a field can depend on that field own value. E.g:
- Validity of
b
depends onb
value - Validity of
e
depends one
value
- Validity of
- Validity of a field can depend on any other field value. E.g:
- Validity of
e
depends oni
andg
values.
- Validity of
- Each field can have own error messages.
- Adding validation should not make me crazy.
- Validation can be Sync/Async
- Sync/Async validation can be run separately
Pros and cons
So main concern which this library addresses is complexity
.
Currently I don't care about perfomance
. It even wasn't measured.
Pros:
- Almost any(?) validation rule can be added.
- Validators / Relations are very flexible to configuration.
- Easy to write unit tests.
- Doesn't have additional dependencies.
- Can be used in different runtimes -
nodejs
orbrowser
. - Different bundles:
-
umd
withes5
-
commonjs
withes6
-
esm
withes6
Cons:
- Sophisticated usage.
- No built-in validators / relations.
- No built-in functionality to display errors in form (for browser).
Examples
There are multiple drivers:
- Plain
- RxJs TBD