Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

functional-jslib/fjl-input-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1efcdb9 · Dec 14, 2022

History

96 Commits
Dec 11, 2018
Jul 25, 2020
Jun 8, 2019
Nov 10, 2018
May 4, 2019
Nov 10, 2018
Dec 11, 2018
May 4, 2019
Dec 16, 2017
May 4, 2019
Nov 10, 2018
May 4, 2019
Nov 10, 2018
Nov 10, 2018
Dec 14, 2022
May 4, 2019
Nov 10, 2018
Jan 20, 2018
Dec 11, 2022
Jun 4, 2021

Repository files navigation

Warning This repo is deprecated. Please see the fjl monorepo for the latest sources.

Build Status GitHub version NPM version Dependencies

fjl-input-filter

Input filter validation functions - These allows you to create input and input-filter objects that can be used (by included utility functions) to easily validate a body of input fields quickly and easily (see usage examples further below).

Sections in Readme:

Basic idea:

  • Validators - Functions that validate a given input and return a validation result.
  • Filters - Functions that take a value and give you a 'possibly' transformed value.
  • Inputs - Objects that contain rules used for validation (breakOnFailure, a list of validators, a list of filters etc.)
  • InputFilters - Collection of input objects that can be validated together as a whole. (see usage example(s) below):

Requirements:

  • Javascript Ecmascript 5+.

Supported Platforms:

Browsers

  • IE9+, and all other modern day browsers.

NodeJs

  • 8+

Getting Started:

In NodeJs:

Using es2015 modules:

import {...} from 'fjl-input-filter';

Using CommonJs modules:

const {...} = require('fjl-input-filter');

In Browser:

See desired export type below:

  • './dist/amd/' - Asynchronous module format.
  • './dist/cjs/' - CommonJs module format.
  • './dist/umd/' - Universal module definition format.
  • './dist/iife/' - Immediately Invoked Function Execution - (exports fjlInputFilter as a global).
  • './dist/es6-module/' - Ecmascript 6 module format.

Docs

JSDocs are here (https://functional-jslib.github.io/fjl-input-filter/) [https://functional-jslib.github.io/fjl-input-filter/].

Docs in readme aren't fully fleshed out yet (see jsdocs, usage examples, and/or tests instead).

Input methods

noValidationRequired, validateInput, validateIOInput, runValidators,
runIOValidators, runFilters, runIOFilters, toInput,
toInputValidationResult, Input

InputFilter methods

validateInputFilter, validateIOInputFilter, validateIOInputWithName,
toInputFilter, toInputFilterResult, InputFilter

In-line summary docs follow:

Api:

validateInputFilter(inputFilter, incomingData)

validateIOInputFilter(inputFilter, incomingData, ioErrorHandler)

validateInput(inputObj, value)

validateIOInput(inputObj, value, ioErrorHandler)

toInputFilter(inputsObj, breakOnFailure {Boolean}, out = {})

toInputFilterResult(resultObj, out = {})

toInputValidationResult(resultObj)

toInput(inputOptions, out = {})

Constructors

Input(options)

Methods

  • validate(data) : InputValidationResult
  • validateIO(data) : Promise.<InputValidationResult>

InputFilter(inputsObj, breakOnFailure {Boolean})

Methods

  • validate(data) : InputFilterResult
  • validateIO(data) : Promise.<InputFilterResult>

Virtual Types

InputValidationResult

InputFilterResult

External Virtual Types

See: fjl-validator repo/module

ValidationResult

ValidatorOptions

Development:

  • For commands see './package.json' scripts.

Dir structure

  • Everything is in './src'.
  • Distribution is in './dist'.
  • Docs are in './docs'.

Testing

Using jest (see './package.json' scripts).

License:

BSD 3 Clause - Included in sources.

Resources:

Change log

1.2.5

  • Dependencies and dev-dependencies updated to latest.
  • Tests updated to reflect updated dev-dependencies (jest complained about nested 'describe' blocks and nested 'test' blocks (primarily issue had to do with async and non-async tests)).

0.18.0

Breaking changes

  • Removed uncurried methods (methods ending with $) (use curried methods instead). Removed:

  • errorIfNotTypeOnTarget$ - ('fjl' provides this now)

  • errorIfNotTypeOnTarget - ("")

  • defineEnumProps$

  • defineProps$

  • Renamed auxillary methods:

    • _descriptorForSettable becomes createTypedDescriptor.
    • _makeDescriptorEnumerable becomes toEnumerableDescriptor.
    • _targetDescriptorTuple becomes toTargetDescriptorTuple.

Other changes:

  • Normalized API (removed un-curried methods from exports and non-api specific (un-required) methods).
  • Updated build process (using babel7 now).
  • Replaced mocha and chai with jest.
  • Changed license from "MIT" to "BSD3".
  • Version and build tag links to top of readme file.
  • Et. al.