not-valid-knockout
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

not-valid-knockout

Interface between knockout and not-valid.

Usage

import { createValidator } from "not-valid";
import { createKnockoutWrapper } from "not-valid-knockout";

const mustBeJames = createValidator<string>(v => v === "James", "Value must be 'James'");

const name = ko.observable<string>();
const nameErrors = ko.observableArray<string>();

const bindValidation = createKnockoutWrapper().bindValidation;

// subscribe to an observable, validate, put errors into an observableArray
bindValidation<string>(
    [ mustBeJames ],
    name,
    nameErrors
);

Testing

If you need to reduce the debounce time for testing you can set the environment variable NOT_VALID_KNOCKOUT_DEBOUNCE.

License

Made with 💖 by NewOrbit in Oxfordshire, and licensed under the MIT License

Readme

Keywords

Package Sidebar

Install

npm i not-valid-knockout

Weekly Downloads

4

Version

2.0.0

License

MIT

Unpacked Size

8.5 kB

Total Files

5

Last publish

Collaborators

  • hisuwh