How to use the juice/validation.Validation.messages function in juice

To help you get started, we’ve selected a few juice examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ashb / juice / test / validation.t.js View on Github external
// neither |message| nor |messages| present
  var no_messages = {
    validation : [ "trim", "notEmpty", "integer" ]
  };
  asserts.throws( function() { v.validateField( no_messages, "" ); },
                  "notEmpty",
                  "notEmpty should throw its name" );
  asserts.throws( function() { v.validateField( no_messages, " " ); },
                  "notEmpty",
                  "notEmpty should throw its name" );
  asserts.throws( function() { v.validateField( no_messages, "foo" ); },
                  "integer",
                  "integer should throw its name" );

  // default messages
  Validation.messages.test = {
    "notEmpty" : "default for notEmpty",
    "integer" : "default for integer"
  };
  asserts.throws( function() { v.validateField( no_messages, "" ); },
                  "default for notEmpty",
                  "notEmpty should throw it's default message" );
  asserts.throws( function() { v.validateField( no_messages, " " ); },
                  "default for notEmpty",
                  "notEmpty should throw it's default message" );
  asserts.throws( function() { v.validateField( no_messages, "foo" ); },
                  "default for integer",
                  "integer should throw it's default message" );
}
github ashb / juice / test / validation.t.js View on Github external
exports.test_ValidateFieldMessages = function () {
  Validation.messages.test = {};
  var v = new Validation( undefined, "test" ); // language is "test" for error messages

  // |message| present
  var one_message = {
    validation : [ "trim", "notEmpty", "integer" ],
    message : "one message"
  };
  asserts.throws( function() { v.validateField( one_message, "" ); },
                  "one message",
                  "All errors should throw single message" );
  asserts.throws( function() { v.validateField( one_message, " " ); },
                  "one message",
                  "All errors should throw single message" );
  asserts.throws( function() { v.validateField( one_message, "foo" ); },
                  "one message",
                  "All errors should throw single message" );