All Projects → KonstantinSimeonov → fluent-schemer

KonstantinSimeonov / fluent-schemer

Licence: MIT license
i wrote this so i can validate stuff without suffering

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to fluent-schemer

ency
Enhanced concurrency primitives for Javascript.
Stars: ✭ 32 (-25.58%)
Mutual labels:  declarative
react-sync
A declarative approach to fetching data via a React higher order component
Stars: ✭ 18 (-58.14%)
Mutual labels:  declarative
react-nes
React components for nes
Stars: ✭ 32 (-25.58%)
Mutual labels:  declarative
carvel-secretgen-controller
secretgen-controller provides CRDs to specify what secrets need to be on Kubernetes cluster (to be generated or not)
Stars: ✭ 54 (+25.58%)
Mutual labels:  declarative
volder
volder is powerful Object schema validation lets you describe your data using a simple and readable schema and transform a value to match the requirements
Stars: ✭ 106 (+146.51%)
Mutual labels:  validation-library
vayder
Easy and concise validations for Express routes
Stars: ✭ 26 (-39.53%)
Mutual labels:  validation-library
pyccolo
Declarative instrumentation for Python.
Stars: ✭ 70 (+62.79%)
Mutual labels:  declarative
FTAPIKit
Declarative and generic REST API framework using Codable.
Stars: ✭ 18 (-58.14%)
Mutual labels:  declarative
definition
Simple and composable validation and coercion of data structures
Stars: ✭ 15 (-65.12%)
Mutual labels:  validation-library
whitelister
Simple, basic filtering and validation tool for Node.js.
Stars: ✭ 46 (+6.98%)
Mutual labels:  validation-library
Processor
Ontology-driven Linked Data processor and server for SPARQL backends. Apache License.
Stars: ✭ 54 (+25.58%)
Mutual labels:  declarative
pianola
A declarative function composition and evaluation engine.
Stars: ✭ 18 (-58.14%)
Mutual labels:  declarative
multibranch-action-triggers-plugin
MultiBranch Actions Trigger Plugin
Stars: ✭ 29 (-32.56%)
Mutual labels:  declarative
react-ratings-declarative
A customizable rating component for selecting x widgets or visualizing x widgets
Stars: ✭ 41 (-4.65%)
Mutual labels:  declarative
tenjin
📝 A template engine.
Stars: ✭ 15 (-65.12%)
Mutual labels:  declarative
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (-13.95%)
Mutual labels:  validation-library
api
_api is an autogenerated CRUD API built on LowDB and ExpressJS.
Stars: ✭ 73 (+69.77%)
Mutual labels:  schema-validation
animation-wrapper-view
Declarative animations with imperative controls for RN/RNW.
Stars: ✭ 53 (+23.26%)
Mutual labels:  declarative
jsbb
JavaScript building blocks
Stars: ✭ 31 (-27.91%)
Mutual labels:  validation-library
mobius-gui
🎨 Reactive & Stream & Driver based UI framework build on Mobius Utils, equipped with neumorphism-derived & utility-first styles.
Stars: ✭ 43 (+0%)
Mutual labels:  declarative

fluent-schemer

Coverage Status Coverage Status

const librarySchema = object({
	dependenciesCount: number().min(0).max(10).integer().optional(),
	name: string().minlength(2).maxlength(10),
	testCoverage: number().min(0).max(100).optional(),
	lastCommitDate: date().after(new Date(new Date().setMonth(new Date().getMonth() - 1))),
	contributors: array(
		object({
			username: string().minlength(5),
			email: string().pattern(/\S+@\S+\.\S+/)
		})
	),
	issues: array(string()),
	activelyMaintained: bool(),
	license: enumeration('MIT', 'BSD', 'GPL')
});

const { errorCounts, errors } = librarySchema.validate(someLibraryRecord);

Incoming:

  • default values, something like
const { corrected: pageSize } = number().min(10).max(100).integer().default(10).validate(-5);
console.log(corrected); // 10

const { corrected: username } = string()
	.minlength(2)
	.maxlength(10)
	.defaultExpression(value => ('_________' + value).slice(0, 10))
	.validate('1');
console.log(username); // _________1

Aims to provide declarative, expressive and elegant approach to validation, while providing an intuitive, easy-to-use api.

It's cool, because

  • it fully embraces ES2015 features such as classes, fat arrow functions, mixins, destructuring statements, modules
  • has typescript type definitions - v2.0 comes with typings for enhanced development experience
  • has flow libdefs, which will soon be available on flow-typed
  • easy to use and pick up, write a little code for a lot of common validation logic
  • has a fluent, readable and declarative api
  • umd compliant - use in node/browser, with commonjs, umd, script tags, harmony modules, whatever
  • no production dependencies, small codebase
  • helps developers get rid of imperative code, long if-else's and writing boring validations all over again
  • promotes code reuse - easily share code between modules, between clients, servers and across projects
  • easy to extends with custom schemas
  • statically type checked with latest typescript, checked for correctness with a bunch of unit tests
  • throws errors when rubbish arguments are provided to schema methods, instead of failing silently

Running the tests

yarn build && yarn lint && yarn test

Examples

Examples can be found in the docs, in the source code and in the tests.

Documentation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].