https://github.com/neworbit/not-valid-knockout
Bindings for validation on knockout observables
https://github.com/neworbit/not-valid-knockout
package
Last synced: about 1 year ago
JSON representation
Bindings for validation on knockout observables
- Host: GitHub
- URL: https://github.com/neworbit/not-valid-knockout
- Owner: NewOrbit
- License: mit
- Created: 2017-05-10T16:00:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-03-24T20:22:10.000Z (about 4 years ago)
- Last Synced: 2024-04-26T05:44:18.850Z (about 2 years ago)
- Topics: package
- Language: TypeScript
- Size: 179 KB
- Stars: 0
- Watchers: 22
- Forks: 1
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# not-valid-knockout
Interface between knockout and [not-valid](https://github.com/NewOrbit/not-valid/).
## Usage
```typescript
import { createValidator } from "not-valid";
import { createKnockoutWrapper } from "not-valid-knockout";
const mustBeJames = createValidator(v => v === "James", "Value must be 'James'");
const name = ko.observable();
const nameErrors = ko.observableArray();
const bindValidation = createKnockoutWrapper().bindValidation;
// subscribe to an observable, validate, put errors into an observableArray
bindValidation(
[ 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](https://www.neworbit.co.uk/) in Oxfordshire, and licensed under the [MIT License](LICENSE)