All Projects → ryansmith94 → rulr

ryansmith94 / rulr

Licence: MIT license
📐 Validation and unit conversion errors in TypeScript at compile-time. Started in 2016.

Programming Languages

typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to rulr

html-sanitizer
HTML sanitizer, written in PHP, aiming to provide XSS-safe markup based on explicitly allowed tags, attributes and values.
Stars: ✭ 18 (-58.14%)
Mutual labels:  sanitization
Mather
A powerful expression-based calculator, unit converter, and general computation engine for Android
Stars: ✭ 49 (+13.95%)
Mutual labels:  unit-conversion
units
A lightweight compile-time, header-only, dimensional analysis and unit conversion library built on c++11 with no dependencies
Stars: ✭ 17 (-60.47%)
Mutual labels:  unit-conversion
mathcore
Advanced .NET math library (.NET Standard).
Stars: ✭ 24 (-44.19%)
Mutual labels:  unit-conversion
pathvalidate
A Python library to sanitize/validate a string such as filenames/file-paths/etc.
Stars: ✭ 139 (+223.26%)
Mutual labels:  sanitization
Sanitize
Ruby HTML and CSS sanitizer.
Stars: ✭ 1,940 (+4411.63%)
Mutual labels:  sanitization
Bluemonday
bluemonday: a fast golang HTML sanitizer (inspired by the OWASP Java HTML Sanitizer) to scrub user generated content of XSS
Stars: ✭ 2,135 (+4865.12%)
Mutual labels:  sanitization
Govalidator
[Go] Package of validators and sanitizers for strings, numerics, slices and structs
Stars: ✭ 5,163 (+11906.98%)
Mutual labels:  sanitization
Validator.js
String validation
Stars: ✭ 18,842 (+43718.6%)
Mutual labels:  sanitization
filter
⏳ Provide filtering, sanitizing, and conversion of Golang data. 提供对Golang数据的过滤,净化,转换。
Stars: ✭ 53 (+23.26%)
Mutual labels:  sanitization
fefe
Validate, sanitize and transform values with proper TypeScript types and zero dependencies.
Stars: ✭ 34 (-20.93%)
Mutual labels:  sanitization
Guten-gutter
Strips boilerplate from Project Gutenberg text files
Stars: ✭ 16 (-62.79%)
Mutual labels:  sanitization
purescript-quantities
Physical quantities and units
Stars: ✭ 44 (+2.33%)
Mutual labels:  unit-conversion
unit-converter
Convert standard units from one to another with this easy to use, lightweight package
Stars: ✭ 104 (+141.86%)
Mutual labels:  unit-conversion
metric.js
ianramosc.github.io/metric.js
Stars: ✭ 29 (-32.56%)
Mutual labels:  unit-conversion

📐
rulr

Validation and unit conversion errors in TypeScript at compile-time.

License: MIT Uses Semantic Release to correctly bump versions especially for breaking changes Uses Renovate to keep dependencies updated Total alerts Language grade: JavaScript Master branch coverage percentage from Codecov Package size from BundlePhobia
// Install it with `npm i rulr`
import * as rulr from 'rulr'

// Compile-time error.
const positiveNumber1: rulr.PositiveNumber = -1

// Run-time error.
const positiveNumber2 = rulr.positiveNumber(-1)

// Convenient rules and guards like `object`.
const example = rulr.object({
	required: {
		price: rulr.positiveNumber,
	},
})

// Turn rules into types to avoid duplicating information.
type Example = rulr.Static<typeof example>

// Turn rules into guards to avoid duplicating code.
const isExample = rulr.guard(example)

// Use rules and/or guards to guarantee your data is valid.
const myExample: Example = example({ price: 12.34 })
if (isExample(myExample)) {
	console.log(myExample.price)
}

Getting Started

To save you some time, Rulr comes with the following rules.

Constraining Strings

Rulr also comes with a growing list of convenient rules for constraining strings that are mostly built on Chris O'Hara's extensive and much loved validator package.

Constraining Non-Strings

In addition to the constrained strings, Rulr also comes with a few convenient rules to help you quickly validate non-string values.

Sanitization Rules

Finally, Rulr is starting to provide rules that sanitize inputs.

Frequently Awesome Questions 🤘

Background

Rulr was started in 2016 and first publicised in 2020. It continues to be maintained to save us time writing validation logic and correcting data by returning as many validation errors as possible in one function call.

Rulr has been influenced by Tom Crockett in RunTypes and more recently Colin McDonnell in Zod. It's hoped that if nothing else, publicising Rulr will influence existing and future validation packages for the better.

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].