Validate anything as you need using a simple higher order function.
NPM:
npm i eyval
Yarn:
yarn add eyval
import eyval from 'eyval'
const isOldEnough = (age: number) => age >= 18
const isYoungEnough = (age: number) => age < 100
const validateAge = eyval<number>(isOldEnough, isYoungEnough)
const validAge = 20
const tooYoung = 14
const tooOld = 200
validateAge(validAge) // returns true
validateAge(tooYoung) // returns false
validateAge(tooOld) // returns false
validator
npm package:import eyval from 'eyval'
import isEmail from 'validator/lib/isEmail'
const validEmailAddress = 'foo@bar.com'
const invalidEmailAddress = 'foo@bar'
const validateEmail = eyval<string>(isEmail)
validateEmail(validEmailAddress) // returns true
validateEmail(invalidEmailAddress) // returns false
You can report bugs and issues here.
You can also send a PR if you feel like you can improve or fix something. Don't forget to write/update tests for your changes.
💮 Algorithms and Data Structures for the modern web
All things that you must learn about it to run on the road into the front-end world.
The Alwatr Library
Personal website that written in React.js & Next.js, Also its user interface design is like apps
A full-featured toolset for Persian Applications Created by Angular (v > 2) containing Pipes, Services, Directives, and javascript Similar Date object for working with Jalali Date.
Opensource Library for the GO programming language
A Visual Studio Code extension for auto typing.
My learning repository, which also contains useful article URLs.