Skip to content

Commit

Permalink
More camelcasing
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldkim committed Sep 23, 2011
1 parent 2783522 commit e69c65a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ property configuration like so:
});

If you would like to override the message for a particular option for all
properties in a configuration, you can pass a *default\_messages* configuration
properties in a configuration, you can pass a *defaultMessages* configuration
like so:

var errors = validations.validate(my_object, {
default_messages: {
defaultMessages: {
length: {
is: "{{name}} must be {{compare_to}} characters in length, no more, no less."
}
Expand Down
2 changes: 1 addition & 1 deletion test/new_suite_prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
this.o = {};
this.validation_config = {
default_messages: {},
defaultMessages: {},
properties: {
p: {}
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_errors_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
this.o = {};
this.validation_config = {
default_messages: {},
defaultMessages: {},
properties: {
p: {}
}
Expand Down
4 changes: 2 additions & 2 deletions test/test_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
this.o = {};
this.validation_config = {
default_messages: {
defaultMessages: {
format: {
pattern: '*{{name}} should match pattern {{compare_to}}.*'
}
Expand All @@ -35,7 +35,7 @@ module.exports = nodeunit.testCase({

function test_format(test) {
var errors, config = this.validation_config,
msg_tmpl = config.default_messages.format.pattern;
msg_tmpl = config.defaultMessages.format.pattern;

test_util.test_val_should_error_tuples([
[undefined, false], [null, false], [0, true], [1, true], ["a", true],
Expand Down
10 changes: 5 additions & 5 deletions test/test_length.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
this.o = {};
this.validation_config = {
default_messages: {
defaultMessages: {
length: {}
},
properties: {
Expand All @@ -32,7 +32,7 @@ module.exports = nodeunit.testCase({

function test_is(test) {
var errors, config = this.validation_config,
msg_tmpl = config.default_messages.required;
msg_tmpl = config.defaultMessages.required;

test_length.call(this, test, "is", "*{{name}} must be of length {{compare_to}}.*", [
[undefined, false], [null, false], [0, false], [1, false],
Expand All @@ -44,7 +44,7 @@ function test_is(test) {

function test_min(test) {
var errors, config = this.validation_config,
msg_tmpl = config.default_messages.required;
msg_tmpl = config.defaultMessages.required;

test_length.call(this, test, "min", "*{{name}} must be at least {{compare_to}} characters.*", [
[undefined, false], [null, false], [0, false], [1, false],
Expand All @@ -56,7 +56,7 @@ function test_min(test) {

function test_max(test) {
var errors, config = this.validation_config,
msg_tmpl = config.default_messages.required;
msg_tmpl = config.defaultMessages.required;

test_length.call(this, test, "max", "*{{name}} must be at most {{compare_to}} characters.*", [
[undefined, false], [null, false], [0, false], [1, false],
Expand All @@ -69,7 +69,7 @@ function test_max(test) {
function test_length(test, length_type, msg_tmpl,
val_should_error_tuples, compare_to) {
var config = this.validation_config;
config.default_messages.length[length_type] = msg_tmpl;
config.defaultMessages.length[length_type] = msg_tmpl;
config.properties.p.length[length_type] =
compare_to == undefined ? true : compare_to;

Expand Down
2 changes: 1 addition & 1 deletion test/test_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
test.o = {};
test.validation_config = {
default_messages: {},
defaultMessages: {},
properties: {
p: {}
}
Expand Down
6 changes: 3 additions & 3 deletions test/test_numericality.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
this.o = {};
this.validation_config = {
default_messages: {
defaultMessages: {
numericality: {}
},
properties: {
Expand Down Expand Up @@ -100,7 +100,7 @@ function test_comparisons(test, comp_type, msg_tmpl, compare_to, val_should_erro
var comp_type = test_config[0], msg_tmpl = test_config[1],
compare_to = test_config[2], val_should_error_tuples = test_config[3];
that.validation_config = {
default_messages: {
defaultMessages: {
numericality: {}
},
properties: {
Expand All @@ -118,7 +118,7 @@ function test_comparisons(test, comp_type, msg_tmpl, compare_to, val_should_erro
function test_num_type(test, num_type, msg_tmpl,
val_should_error_tuples, compare_to) {
var config = this.validation_config;
config.default_messages.numericality[num_type] = msg_tmpl;
config.defaultMessages.numericality[num_type] = msg_tmpl;
config.properties.p.numericality[num_type] =
compare_to == undefined ? true : compare_to;

Expand Down
2 changes: 1 addition & 1 deletion test/test_recursion.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
test.o = {};
test.validation_config = {
default_messages: {},
defaultMessages: {},
properties: {
p: {}
}
Expand Down
4 changes: 2 additions & 2 deletions test/test_required.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = nodeunit.testCase({
setUp: function(callback) {
this.o = {};
this.validation_config = {
default_messages: {
defaultMessages: {
required: '*{{name}} is required.*'
},
properties: {
Expand All @@ -31,7 +31,7 @@ module.exports = nodeunit.testCase({

function test_required(test) {
var errors, config = this.validation_config,
msg_tmpl = config.default_messages.required;
msg_tmpl = config.defaultMessages.required;

test_util.test_val_should_error_tuples([
[undefined, true], [null, true], ["", true], [0, false],
Expand Down
14 changes: 7 additions & 7 deletions validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _.humanize = function(s) {
return _(s).underscored().replace('_', ' ');
}

var global_default_messages = {
var globalDefaultMessages = {
required: "{{name}} is required.",
length: {
is: "{{name}} must be exactly {{compare_to}} characters.",
Expand Down Expand Up @@ -125,9 +125,9 @@ var interpolation_scope_extractors = {
exports.validate = function validate(obj, config) {

var errors = newErrors();
var default_messages = config.default_messages || {};
var defaultMessages = config.defaultMessages || {};
_.without(validation_types, 'required').forEach(function(validation_type) {
if (!default_messages[validation_type]) default_messages[validation_type] = {};
if (!defaultMessages[validation_type]) defaultMessages[validation_type] = {};
});

function test_and_add_error_message(prop_name, prop_config, validation_type, value, subtype) {
Expand All @@ -147,11 +147,11 @@ exports.validate = function validate(obj, config) {
if (!valid_func(value, compare_to)) {
var msg = prop_config.message;
if (subtype) {
msg = msg || default_messages[validation_type][subtype] ||
global_default_messages[validation_type][subtype];
msg = msg || defaultMessages[validation_type][subtype] ||
globalDefaultMessages[validation_type][subtype];
} else {
msg = msg || default_messages[validation_type] ||
global_default_messages[validation_type];
msg = msg || defaultMessages[validation_type] ||
globalDefaultMessages[validation_type];
}
var vars;
if (interpolation_scope_extractor)
Expand Down

0 comments on commit e69c65a

Please sign in to comment.