Comparing version 0.1.0 to 0.2.0
19
frete.js
@@ -95,2 +95,4 @@ 'use strict'; | ||
this.errors = []; | ||
self.options = opts; | ||
@@ -245,5 +247,8 @@ allOptions.forEach(function (opt) { | ||
V.string(cep, 'cep'); | ||
V.function(callback, 'callback'); | ||
if (!V.isString(cep)) { | ||
this.errors.push("Missing/invalid value for sCepDestino."); | ||
} | ||
opts.sCepDestino = cep; | ||
@@ -260,3 +265,3 @@ | ||
let errors = getValidationErrors(methodName, opts); | ||
let errors = this.errors.concat(getValidationErrors(methodName, opts)); | ||
if (errors.length > 0) { | ||
@@ -376,3 +381,2 @@ let err = new Error("Validation error:\n" + errors.join("\n")); | ||
// special case for DataCalculo | ||
// PO!! Parece que o pessoal dos correios tem nenhum pattern! f*ck :( | ||
let prettyNameMethod; | ||
@@ -397,8 +401,11 @@ if (propertyName === 'strDataCalculo') { | ||
if (isString) { | ||
V.string(value, 'value'); | ||
if (!V.isString(value)) { | ||
this.errors.push("Invalid string value for " + propertyName + " : " + value); | ||
} | ||
} else if (isNumber) { | ||
V.number(value, 'value'); | ||
if (!V.isNumber(value)) { | ||
this.errors.push("Invalid number value for " + propertyName + " : " + value); | ||
} | ||
} | ||
// MUST: validate service | ||
optionsObject[propertyName] = value; | ||
@@ -405,0 +412,0 @@ return this; |
@@ -73,9 +73,4 @@ 'use strict'; | ||
f.servico(frete.codigos.sedex); | ||
f.cepOrigem(''); | ||
assert.throws(function () { | ||
f.cepOrigem(''); | ||
}, /Invalid string value/) | ||
f.options.sCepOrigem = ''; | ||
f.prazo('13466321', function (err) { | ||
@@ -82,0 +77,0 @@ assert.equal(/Required option: sCepOrigem has invalid value/.test(err.message), true) |
{ | ||
"name": "frete", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Modulo para consumo da API de frete dos correios brasileiros.", | ||
@@ -5,0 +5,0 @@ "main": "frete.js", |
@@ -22,3 +22,3 @@ Frete | ||
Todas as opcoes do `wsdl` estao disponíveis via os mesmos comandos, e os metodos estao disponíveis nos mesmos nomes mas em `camelCase`. | ||
Todas as opcoes do `wsdl` estao disponíveis via os mesmos comandos, e os metodos estao disponíveis nos mesmos nomes mas em `camelCase` e sem o prefixo `Calc`, (e.g. `.precoPrazo()`). | ||
@@ -25,0 +25,0 @@ ## Exemplos |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69681
521