2.0.0 • Published 5 years ago

not-valid-knockout v2.0.0

Weekly downloads
30
License
MIT
Repository
github
Last release
5 years ago

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 :sparkling_heart: by NewOrbit in Oxfordshire, and licensed under the MIT License

2.0.0

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago