Socket
Socket
Sign inDemoInstall

ember-changeset-hofs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-changeset-hofs

The default blueprint for ember-cli addons.


Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

ember-changeset-hofs

Higher-order validation functions for ember-changeset-validations.

For background info, please see the thread here.

This addon provides and and or higher-order functions, that allow you to compose together validations. It is useful if you want the short-circuit behavior of && and ||. For example:

// app/validations/user.js
import and from 'ember-changeset-hofs/utils/and'
import or from 'ember-changeset-hofs/utils/or'

export const {
  email: and(
    validateFormat({ type: 'email' }),
    askServerIfExists(), // will not get called if validateFormat fails
  ),

  anotherEmail: or(
    isUndefinedOrNull(),
    askServerIfExists(), // will not get called if isUndefinedOrNull succeeds
  ),
}

Note that the and and or utils work with both synchronous and asynchronous validators. You can nest and and or expressions arbitrarily, and you can mix sync and async validators however you want:

const validationFn = and(
  and(
    and(...someValidators),
    or(...someMoreValidators),
    or(
      or(...someValidators),
      and(...someMoreValidators),
    )
  ),
  or(...evenMoreValidators)
)

Install

$ ember install ember-changeset-hofs

License

MIT

Keywords

FAQs

Package last updated on 07 Oct 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc