Parsley validation for Knockout JS.

npm install knockout-parsley
19 downloads in the last week
41 downloads in the last month

Knockout Parsley

Parsley validation for Knockout JS.

License: MIT


// Init the plugin

var viewModel = {
  // Add a simple rule to the observable
  value1:  ko.observable().extend({ required: true }),

  // Add rule with custom message
  value2: ko.observable().extend({
    type: { 
      params: "email",
      message: "This is not a valid email address!"

  // Add rule with condition
  // The condition must be a function returning  a boolean value. 
  // If the returned value is false, the validation will not apply.
  value3: ko.observable().extend({
    required: {
      params: true,
      condition: function(_viewModel) {
        return _viewModel.value1() === 'Some Text';

// Apply Knockout bindings


You can use the following Parsley rules:

  • required
  • minlength
  • maxlength
  • length
  • min
  • max
  • pattern
  • range
  • type

Learn more about the rules on the Parsley Documentation Site

npm loves you