
Company News
Andrew Becherer Joins Socket as Chief Information Security Officer
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.
@validarium/core
Advanced tools
Platform-agnostic validation library for JavaScript applications with extra focus on composable validations and message translations. Includes (pretty much) out-of-the-box support for both Redux Form and React Intl.
Create your validation schema based on priciples of functional programming.
Open Validarium in a RunKit sandbox!
This package contains all core functionalities for Validarium. ## API referenceThis package contains all core functionalities for Validarium.
ObjectObject | nullApplies validations in descriptor for value.
Params are curried.
Sig: Object -> a -> b
| Param | Type | Description |
|---|---|---|
| descriptor | object | Object that contains validations for each item in values |
| value | any | Value for validation |
Example
validate({
id: [(x) => !x && 'Is required.', (x) => x < 0 && 'Must be greater than 0.'],
name: [(x) => !x && 'Is required.'],
surname: [(x) => !x && 'Is required.'],
}, {
id: -1,
surname: 'Doe',
}
])
// Output:
// {
// id: 'Must be greater than 0.',
// name: 'Is required.',
// surname: false,
// }
Applies validations in descriptor for each item in values.
Params are curried.
Sig: Object -> [Object] -> [Object]
| Param | Type | Description |
|---|---|---|
| descriptor | object | Object that contains validations for each item in values |
| values | array | Values for validations |
Example
validateMany({
id: [(x) => !x && 'Is required.', (x) => x < 0 && 'Must be greater than 0.'],
name: [(x) => !x && 'Is required.'],
surname: [(x) => !x && 'Is required.'],
}, [
{
id: -1,
surname: 'Doe',
},
{
id: 13,
name: 'Bob',
},
])
// Output:
// [
// {
// id: 'Must be greater than 0.',
// name: 'Is required.',
// surname: false,
// }, {
// id: false,
// name: false,
// surname: 'Is required.',
// },
// ]
ObjectCombine multiple validate schemes into one. If multiple schemes contains same validation, then the error validation * always wins.
Returns: Object - Merged result result.
| Param | Type | Description |
|---|---|---|
| ...fns | function | Validation functions. |
| values | any |
Object | nullCreates validation function with predicate and message. Results of validation is ready for translation by react-intl. Result is valid if nil or empty is passed. Use required validation if you want to ensure that field is required.
Returns: Object | null - Message object when fails { message, messageValues } or null if pass
| Param | Type | Description |
|---|---|---|
| fn | function | validation predicate. |
| react | String | intl message (eg. { id: 1, defaultMessage: '' }) |
| params | Object | for intl message (eg. { min: 1, max: 2 }) |
Example
> const hasLength = length => createValidation(hasLength(length), m.hasLength, { length })
> hasLength(6)('abcdef')
null
All packages are distributed under the MIT license. See the license here.
FAQs
Main functionality of @validarium lays here.
The npm package @validarium/core receives a total of 66 weekly downloads. As such, @validarium/core popularity was classified as not popular.
We found that @validarium/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.