validate.js
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "validate.js", | ||
"main": ["validate.js", "validate.min.js"], | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"ignore": [ | ||
@@ -6,0 +6,0 @@ "**/.*", |
@@ -48,3 +48,3 @@ module.exports = function(grunt) { | ||
files: ['specs/**/*.js', '<%= pkg.name %>'], | ||
tasks: ['jasmine'], | ||
tasks: ['jasmine:specs', 'jasmine:coverage'], | ||
options: { | ||
@@ -63,2 +63,4 @@ atBegin: true | ||
helpers: "specs/helpers.js", | ||
display: "short", | ||
summary: true | ||
} | ||
@@ -72,2 +74,3 @@ }, | ||
helpers: "<%= jasmine.specs.options.helpers %>", | ||
display: "none", | ||
template: require('grunt-template-jasmine-istanbul'), | ||
@@ -108,3 +111,4 @@ templateOptions: { | ||
options: { | ||
sourceMap: 'validate.min.map' | ||
sourceMap: true, | ||
sourceMapName: 'validate.min.map' | ||
} | ||
@@ -111,0 +115,0 @@ } |
{ | ||
"name": "validate.js", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"author": "Nicklas Ansman <nicklas@ansman.se>", | ||
@@ -25,11 +25,11 @@ "description": "Declarative validations for JavaScript", | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt-notify": "~0.2.13", | ||
"grunt-contrib-watch": "~0.5.2", | ||
"grunt-contrib-jshint": "~0.7.0", | ||
"grunt-contrib-uglify": "~0.2.4", | ||
"grunt-contrib-jasmine": "~0.5.2", | ||
"grunt-docco": "~0.3.0", | ||
"grunt-template-jasmine-istanbul": "~0.2.5", | ||
"coveralls": "~2.5.0" | ||
"grunt": "0.4.5", | ||
"grunt-notify": "0.4.1", | ||
"grunt-contrib-watch": "0.6.1", | ||
"grunt-contrib-jshint": "0.11.0", | ||
"grunt-contrib-uglify": "0.8.0", | ||
"grunt-contrib-jasmine": "0.8.2", | ||
"grunt-docco": "0.3.3", | ||
"grunt-template-jasmine-istanbul": "0.3.3", | ||
"coveralls": "2.11.2" | ||
}, | ||
@@ -36,0 +36,0 @@ "licenses": [{ |
@@ -9,6 +9,26 @@ validate.js | ||
Building validate.js | ||
--- | ||
### Requirements | ||
* [node.js](https://nodejs.org/) - Will probably work with most versions | ||
* [grunt-cli](http://gruntjs.com/using-the-cli) | ||
### Build steps | ||
1. `git clone git@github.com:ansman/validate.js.git` | ||
2. `cd validate.js` | ||
3. `npm install` | ||
4. `grunt build` | ||
This will build *validate.min.js*, *validate.min.map* and the *docs* folder. | ||
### Continuous testing | ||
You can run continuous testing that runs the tests on file changes by running | ||
`grunt watch` or simply `grunt`. | ||
If you want to just run the tests once you can do that by running `grunt test`. | ||
Build status | ||
--- | ||
[](https://travis-ci.org/ansman/validate.js) | ||
[](https://coveralls.io/r/ansman/validate.js?branch=master) | ||
[](https://coveralls.io/r/ansman/validate.js?branch=master) | ||
@@ -19,1 +39,7 @@ Contributing | ||
[contribution guidelines](https://github.com/ansman/validate.js/blob/master/CONTRIBUTING.md). | ||
Users of validate.js | ||
--- | ||
If your site, library or application uses validate.js and would like to be shown | ||
here please feel free to email <a href="mailto:validate@ansman.se">validate@ansman.se</a> | ||
with the name and optionally a URL to the project and it will be added here. |
beforeEach(function() { | ||
this.addMatchers({ | ||
toHaveLength: function(expected) { | ||
return this.actual.length === expected; | ||
jasmine.addMatchers({ | ||
toHaveLength: function(util, customEqualityTesters) { | ||
return { | ||
compare: function(actual, expected) { | ||
return { | ||
pass: actual.length === expected | ||
}; | ||
} | ||
}; | ||
}, | ||
toHaveBeenCalledWithContext: function(context) { | ||
return this.actual.calls.some(function(call) { | ||
return call.object === context; | ||
}); | ||
toHaveBeenCalledWithContext: function(util, customEqualityTesters) { | ||
return { | ||
compare: function(actual, expected) { | ||
return { | ||
pass: actual.calls.any(function(call) { | ||
return call.object === expected; | ||
}) | ||
}; | ||
} | ||
}; | ||
}, | ||
toHaveItems: function(items) { | ||
if (this.actual.length != items.length) { | ||
return false; | ||
} | ||
return this.actual.every(function(a) { | ||
return items.some(function(item) { | ||
return JSON.stringify(item) === JSON.stringify(a); | ||
}); | ||
}); | ||
toHaveItems: function(util, customEqualityTesters) { | ||
return { | ||
compare: function(actual, expected) { | ||
if (actual.length != expected.length) { | ||
return {pass: false}; | ||
} | ||
return { | ||
pass: actual.every(function(a) { | ||
return expected.some(function(item) { | ||
return JSON.stringify(item) === JSON.stringify(a); | ||
}); | ||
}) | ||
}; | ||
} | ||
}; | ||
}, | ||
toBeInstanceOf: function(constructor) { | ||
return this.actual instanceof constructor; | ||
toBeInstanceOf: function(util, customEqualityTesters) { | ||
return { | ||
compare: function(actual, expected) { | ||
return { | ||
pass: actual instanceof expected | ||
}; | ||
} | ||
}; | ||
}, | ||
toBeAPromise: function() { | ||
return this.actual && typeof this.actual.then === "function"; | ||
toBeAPromise: function(util, customEqualityTesters) { | ||
return { | ||
compare: function(actual, expected) { | ||
return { | ||
pass: actual && typeof actual.then === "function" | ||
}; | ||
} | ||
}; | ||
} | ||
}); | ||
}); |
describe("validate.async", function() { | ||
var error = null | ||
, success = null; | ||
, success = null | ||
, Promise = validate.Promise; | ||
@@ -10,3 +11,3 @@ beforeEach(function() { | ||
validate.validators.asyncFail = function() { | ||
return validate.Promise(function(resolve, reject) { | ||
return new validate.Promise(function(resolve, reject) { | ||
setTimeout(function() { | ||
@@ -19,3 +20,3 @@ reject("failz"); | ||
validate.validators.asyncSuccess = function() { | ||
return validate.Promise(function(resolve, reject) { | ||
return new validate.Promise(function(resolve, reject) { | ||
setTimeout(function() { | ||
@@ -32,2 +33,3 @@ resolve(); | ||
delete validate.async.options; | ||
validate.Promise = Promise; | ||
}); | ||
@@ -40,2 +42,17 @@ | ||
it("throws an error if no promise is found", function() { | ||
delete validate.Promise; | ||
expect(function() { | ||
validate.async({}, {}); | ||
}).toThrow(); | ||
}); | ||
it("allows you to specify a custom Promise implementation", function() { | ||
spyOn(validate, "Promise").and.callFake(function(func) { | ||
return new Promise(func); | ||
}); | ||
var promise = validate.async({}, {}); | ||
expect(validate.Promise).toHaveBeenCalled(); | ||
}); | ||
it.promise("resolves the promise if all constraints pass", function() { | ||
@@ -57,34 +74,3 @@ var attrs = {foo: "bar"}; | ||
it.promise("rejects the promise with an errors object when failing", function() { | ||
var c = {name: {presence: true}}; | ||
var called = false; | ||
return validate.async({}, c) | ||
.then(success, function(err) { | ||
called = true; | ||
expect(err).toBeInstanceOf(validate.ValidationErrors); | ||
expect(err).toEqual({ | ||
name: ["Name can't be blank"] | ||
}); | ||
}) | ||
.then(function() { | ||
expect(success).not.toHaveBeenCalled(); | ||
expect(called).toBe(true); | ||
}); | ||
}); | ||
it.promise("doesn't wrap flat errors in an object", function() { | ||
var c = {name: {presence: true}}; | ||
var called = false; | ||
return validate.async({}, c, {flatten: true}) | ||
.then(success, function(err) { | ||
called = true; | ||
expect(err).not.toBeInstanceOf(validate.ValidationErrors); | ||
expect(err).toEqual(["Name can't be blank"]); | ||
}) | ||
.then(function() { | ||
expect(success).not.toHaveBeenCalled(); | ||
expect(called).toBe(true); | ||
}); | ||
}); | ||
it.promise("handles validators returning a promise", function() { | ||
@@ -115,107 +101,2 @@ var c = { | ||
describe("Promise", function() { | ||
var globals = ["Promise", "Q", "when", "RSVP"] | ||
, store = {}; | ||
globals.forEach(function(name) { store[name] = window[name]; }); | ||
beforeEach(function() { | ||
globals.forEach(function(name) { window[name] = undefined; }); | ||
}); | ||
afterEach(function() { | ||
globals.forEach(function(name) { window[name] = store[name]; }); | ||
}); | ||
it("throws an error if no promise can be detected", function() { | ||
expect(function() { new validate.Promise(); }).toThrow(); | ||
}); | ||
it("tries to import each promise", function() { | ||
spyOn(validate, "tryRequire").andReturn(null); | ||
expect(function() { new validate.Promise(); }).toThrow(); | ||
expect(validate.tryRequire).toHaveBeenCalledWith("es6-promise"); | ||
expect(validate.tryRequire).toHaveBeenCalledWith("rsvp"); | ||
expect(validate.tryRequire).toHaveBeenCalledWith("when"); | ||
expect(validate.tryRequire).toHaveBeenCalledWith("q"); | ||
}); | ||
it("supports native promises", function() { | ||
var callback = jasmine.createSpy("callback"); | ||
window.Promise = store.Promise; | ||
promise = new validate.Promise(callback); | ||
expect(promise).toBeInstanceOf(Promise); | ||
expect(callback).toHaveBeenCalled(); | ||
}); | ||
it("tries to import the native promised polyfill", function() { | ||
spyOn(validate, "tryRequire").andCallFake(function(module) { | ||
if (module === "es6-promise") { | ||
return {Promise: store.Promise}; | ||
} else { | ||
return null; | ||
} | ||
}); | ||
expect(validate.Promise(function() {})).toBeAPromise(); | ||
}); | ||
it("supports RSVP promises", function() { | ||
var callback = jasmine.createSpy("callback"); | ||
window.RSVP = store.RSVP; | ||
promise = new validate.Promise(callback); | ||
expect(promise).toBeInstanceOf(RSVP.Promise); | ||
expect(callback).toHaveBeenCalled(); | ||
}); | ||
it("tries to import the RSVP module", function() { | ||
spyOn(validate, "tryRequire").andCallFake(function(module) { | ||
if (module === "rsvp") { | ||
return store.RSVP; | ||
} else { | ||
return null; | ||
} | ||
}); | ||
expect(validate.Promise(function() {})).toBeAPromise(); | ||
}); | ||
it("supports when.js promises", function() { | ||
var callback = jasmine.createSpy("callback"); | ||
window.when = store.when; | ||
promise = new validate.Promise(callback); | ||
expect(when.isPromiseLike(promise)).toBe(true); | ||
expect(callback).toHaveBeenCalled(); | ||
}); | ||
it("tries to import the when.js module", function() { | ||
spyOn(validate, "tryRequire").andCallFake(function(module) { | ||
console.log(module); | ||
if (module === "when") { | ||
return store.when; | ||
} else { | ||
return null; | ||
} | ||
}); | ||
expect(validate.Promise(function() {})).toBeAPromise(); | ||
}); | ||
it("supports Q promises", function() { | ||
var callback = jasmine.createSpy("callback"); | ||
window.Q = store.Q; | ||
promise = new validate.Promise(callback); | ||
expect(Q.isPromise(promise)).toBe(true); | ||
expect(callback).toHaveBeenCalled(); | ||
}); | ||
it("tries to import the q module", function() { | ||
spyOn(validate, "tryRequire").andCallFake(function(module) { | ||
if (module === "q") { | ||
return store.Q; | ||
} else { | ||
return null; | ||
} | ||
}); | ||
expect(validate.Promise(function() {})).toBeAPromise(); | ||
}); | ||
}); | ||
describe("waitForResults", function() { | ||
@@ -243,3 +124,3 @@ var error, success; | ||
attribute: "foo", | ||
error: validate.Promise(function(resolve, reject) { | ||
error: new validate.Promise(function(resolve, reject) { | ||
setTimeout(resolve, 1); | ||
@@ -249,3 +130,3 @@ }) | ||
attribute: "bar", | ||
error: validate.Promise(function(resolve, reject) { | ||
error: new validate.Promise(function(resolve, reject) { | ||
setTimeout(reject.bind(this, "My error"), 1); | ||
@@ -277,3 +158,3 @@ }) | ||
attribute: "foo", | ||
error: validate.Promise(function(resolve, reject) { reject(); }) | ||
error: new validate.Promise(function(resolve, reject) { reject(); }) | ||
}]; | ||
@@ -280,0 +161,0 @@ |
@@ -27,3 +27,3 @@ describe("validate", function() { | ||
it("calls the argument if it's a function and returns the result", function() { | ||
var obj = jasmine.createSpy().andReturn("some return value"); | ||
var obj = jasmine.createSpy().and.returnValue("some return value"); | ||
expect(validate.result(obj)).toEqual("some return value"); | ||
@@ -124,2 +124,7 @@ }); | ||
}); | ||
it("supports escaping %", function() { | ||
var actual = validate.format("Foo is %%{foo}", {foo: "foo"}); | ||
expect(actual).toEqual("Foo is %{foo}"); | ||
}); | ||
}); | ||
@@ -354,3 +359,3 @@ | ||
var defineSpy = jasmine.createSpy('define').andCallFake(define); | ||
var defineSpy = jasmine.createSpy('define').and.callFake(define); | ||
@@ -404,4 +409,4 @@ exposeModule(validate, root, null, null, defineSpy); | ||
it("does not nothing if the console isn't defined", function() { | ||
validate.warn("Msg"); | ||
it("does nothing if the console isn't defined", function() { | ||
expect(function() { validate.warn("Msg"); }).not.toThrow(); | ||
}); | ||
@@ -424,4 +429,5 @@ | ||
it("does not nothing if the console isn't defined", function() { | ||
it("does nothing if the console isn't defined", function() { | ||
validate.error("Msg"); | ||
expect(function() { validate.error("Msg"); }).not.toThrow(); | ||
}); | ||
@@ -438,26 +444,2 @@ | ||
describe("tryRequire", function() { | ||
var require = validate.require; | ||
beforeEach(function() { validate.require = null; }); | ||
afterEach(function() { validate.require = require; }); | ||
it("returns null if v.require isn't defined", function() { | ||
expect(validate.tryRequire("foobar")).toBe(null); | ||
}); | ||
it("returns the imported module if found", function() { | ||
var module = {foo: "bar"}; | ||
spyOn(validate, "require").andReturn(module); | ||
expect(validate.tryRequire("foobar")).toBe(module); | ||
expect(validate.require).toHaveBeenCalledWith("foobar"); | ||
}); | ||
it("returns null if the module isn't found", function() { | ||
spyOn(validate, "require").andThrow(new Error("Not found")); | ||
expect(validate.tryRequire("foobar")).toBe(null); | ||
expect(validate.require).toHaveBeenCalledWith("foobar"); | ||
}); | ||
}); | ||
describe("getDeepObjectValue", function() { | ||
@@ -464,0 +446,0 @@ it("supports multiple keys separated using a period", function() { |
@@ -9,4 +9,4 @@ describe("validate", function() { | ||
beforeEach(function() { | ||
fail = jasmine.createSpy('failValidator').andReturn("my error"); | ||
fail2 = jasmine.createSpy('failValidator2').andReturn("my error"); | ||
fail = jasmine.createSpy('failValidator').and.returnValue("my error"); | ||
fail2 = jasmine.createSpy('failValidator2').and.returnValue("my error"); | ||
pass = jasmine.createSpy('passValidator'); | ||
@@ -29,3 +29,3 @@ pass2 = jasmine.createSpy('passValidator2'); | ||
it("raises an error if a promise is returned", function() { | ||
fail.andReturn(validate.Promise(function() {})); | ||
fail.and.returnValue(new validate.Promise(function() {})); | ||
var constraints = {name: {fail: true}}; | ||
@@ -64,4 +64,4 @@ expect(function() { validate({}, constraints); }).toThrow(); | ||
fail.andReturn("must be a valid email address"); | ||
fail2.andReturn("is simply not good enough"); | ||
fail.and.returnValue("must be a valid email address"); | ||
fail2.and.returnValue("is simply not good enough"); | ||
@@ -98,3 +98,3 @@ expect(validate(attributes, constraints)).toEqual({ | ||
validate.runValidations({}, {name: {foobar: true}}, {}); | ||
}).toThrow("Unknown validator foobar"); | ||
}).toThrow(new Error("Unknown validator foobar")); | ||
}); | ||
@@ -119,5 +119,5 @@ | ||
it("returns an array of results", function() { | ||
fail.andReturn("foobar"); | ||
fail2.andReturn(["foo", "bar"]); | ||
pass.andReturn(null); | ||
fail.and.returnValue("foobar"); | ||
fail2.and.returnValue(["foo", "bar"]); | ||
pass.and.returnValue(null); | ||
@@ -141,3 +141,3 @@ var options = {someOption: true} | ||
it("validates all attributes", function() { | ||
fail.andReturn("error"); | ||
fail.and.returnValue("error"); | ||
var constraints = { | ||
@@ -158,3 +158,3 @@ attr1: {pass: true}, | ||
, attrs = {name: "Nicklas"} | ||
, spy = jasmine.createSpy("options").andReturn(options) | ||
, spy = jasmine.createSpy("options").and.returnValue(options) | ||
, constraints = {name: spy} | ||
@@ -170,3 +170,3 @@ , globalOptions = {foo: "bar"}; | ||
, attrs = {name: "Nicklas"} | ||
, spy = jasmine.createSpy("options").andReturn(options) | ||
, spy = jasmine.createSpy("options").and.returnValue(options) | ||
, constraints = {name: {pass: spy}} | ||
@@ -187,4 +187,4 @@ , globalOptions = {foo: "bar"}; | ||
form.innerHTML = '<input type="text" name="foo" value="bar">'; | ||
spyOn(validate, "collectFormValues").andCallThrough(); | ||
spyOn(validate.validators, "presence").andCallThrough(); | ||
spyOn(validate, "collectFormValues").and.callThrough(); | ||
spyOn(validate.validators, "presence").and.callThrough(); | ||
var constraints = {foo: {presence: true}}; | ||
@@ -248,3 +248,3 @@ validate(form, constraints); | ||
describe("works with flatten: true and fullMessages: false", function() { | ||
it("works with flatten: true and fullMessages: false", function() { | ||
var constraints = {foo: {presence: true}} | ||
@@ -263,2 +263,28 @@ , options = {flatten: true, fullMessages: false}; | ||
}); | ||
describe("single", function() { | ||
it("validates the single property", function() { | ||
var validators = { | ||
presence: { | ||
message: "example message" | ||
}, | ||
length: { | ||
is: 6, | ||
message: "^It needs to be 6 characters long" | ||
} | ||
}; | ||
expect(validate.single(null, validators)).toEqual(["example message"]); | ||
expect(validate.single("foo", validators)).toEqual(["It needs to be 6 characters long"]); | ||
expect(validate.single("foobar", validators)).not.toBeDefined(); | ||
}); | ||
it("ignores the flatten and fullMessages options", function() { | ||
var validators = {presence: true} | ||
, options = {flatten: false, fullMessages: true}; | ||
expect(validate.single(null, validators, options)) | ||
.toEqual(["can't be blank"]); | ||
}); | ||
}); | ||
}); |
describe('validators.datetime', function() { | ||
var datetime = validate.validators.datetime.bind(validate.validators.datetime) | ||
, XDate = window.XDate | ||
, moment = window.moment; | ||
, XDate = validate.XDate | ||
, moment = validate.moment; | ||
afterEach(function() { | ||
window.XDate = XDate; | ||
window.moment = undefined; | ||
delete validate.validators.datetime.notValid; | ||
@@ -13,2 +11,4 @@ delete validate.validators.datetime.tooEarly; | ||
delete validate.validators.datetime.options; | ||
validate.XDate = XDate; | ||
validate.moment = moment; | ||
}); | ||
@@ -26,5 +26,8 @@ | ||
it("throws and error if neither XDate or moment.js is found", function() { | ||
window.XDate = null; | ||
spyOn(validate, 'tryRequire').andReturn(null); | ||
beforeEach(function() { | ||
delete validate.XDate; | ||
delete validate.moment; | ||
}); | ||
it("throws an error if neither XDate or moment.js is found", function() { | ||
expect(function() { | ||
@@ -54,3 +57,3 @@ parse("2014-09-02"); | ||
beforeEach(function() { | ||
spyOn(validate, "tryRequire").andReturn(null); | ||
validate.XDate = XDate; | ||
}); | ||
@@ -69,5 +72,4 @@ | ||
beforeEach(function() { | ||
window.XDate = undefined; | ||
spyOn(moment, "utc").andCallThrough(); | ||
spyOn(validate, "tryRequire").andReturn(moment); | ||
validate.moment = moment; | ||
spyOn(moment, "utc").and.callThrough(); | ||
}); | ||
@@ -84,9 +86,2 @@ | ||
}); | ||
it("works with global scope too", function() { | ||
window.moment = moment; | ||
validate.tryRequire.andReturn(null); | ||
runParseTestsForValidStrings(); | ||
expect(moment.utc).toHaveBeenCalled(); | ||
}); | ||
}); | ||
@@ -98,5 +93,8 @@ }); | ||
beforeEach(function() { | ||
delete validate.XDate; | ||
delete validate.moment; | ||
}); | ||
it("throws and error if neither XDate or moment.js is found", function() { | ||
window.XDate = null; | ||
spyOn(validate, 'tryRequire').andReturn(null); | ||
expect(function() { | ||
@@ -124,3 +122,3 @@ format(1382808924000, {}); | ||
beforeEach(function() { | ||
spyOn(validate, "tryRequire").andReturn(null); | ||
validate.XDate = XDate; | ||
}); | ||
@@ -143,5 +141,4 @@ | ||
beforeEach(function() { | ||
window.XDate = undefined; | ||
spyOn(moment, "utc").andCallThrough(); | ||
spyOn(validate, "tryRequire").andReturn(moment); | ||
validate.moment = moment; | ||
spyOn(moment, "utc").and.callThrough(); | ||
}); | ||
@@ -163,9 +160,2 @@ | ||
}); | ||
it("works with global scope too", function() { | ||
window.moment = moment; | ||
validate.tryRequire.andReturn(null); | ||
runDatetimeTest(); | ||
expect(moment.utc).toHaveBeenCalled(); | ||
}); | ||
}); | ||
@@ -184,3 +174,3 @@ }); | ||
it("uses the parse function to validate dates", function() { | ||
var spy = spyOn(validate.validators.datetime, 'parse').andReturn(NaN) | ||
var spy = spyOn(validate.validators.datetime, 'parse').and.returnValue(NaN) | ||
, options = {foo: "bar"}; | ||
@@ -226,3 +216,3 @@ expect(datetime("2013-06-27", options)).toBeDefined(); | ||
, value = "2013-10-25 00:00:00" | ||
, spy = spyOn(validate.validators.datetime, 'format').andReturn("foobar") | ||
, spy = spyOn(validate.validators.datetime, 'format').and.returnValue("foobar") | ||
, expected = ["must be no earlier than foobar"]; | ||
@@ -235,3 +225,3 @@ expect(datetime(value, options)).toEqual(expected); | ||
, value = XDate.today() | ||
, spy = spyOn(validate.validators.datetime, 'parse').andReturn(value); | ||
, spy = spyOn(validate.validators.datetime, 'parse').and.returnValue(value); | ||
datetime(value, options); | ||
@@ -273,3 +263,3 @@ expect(spy).toHaveBeenCalledWith('foobar', options); | ||
, value = "2013-10-27 00:00:00" | ||
, spy = spyOn(validate.validators.datetime, 'format').andReturn("foobar") | ||
, spy = spyOn(validate.validators.datetime, 'format').and.returnValue("foobar") | ||
, expected = ["must be no later than foobar"]; | ||
@@ -282,3 +272,3 @@ expect(datetime(value, options)).toEqual(expected); | ||
, value = XDate.today() | ||
, spy = spyOn(validate.validators.datetime, 'parse').andReturn(value); | ||
, spy = spyOn(validate.validators.datetime, 'parse').and.returnValue(value); | ||
datetime(value, options); | ||
@@ -337,3 +327,3 @@ expect(spy).toHaveBeenCalledWith('foobar', options); | ||
, options = {foo: "bar"} | ||
, spy = spyOn(validate.validators, 'datetime').andReturn(errors); | ||
, spy = spyOn(validate.validators, 'datetime').and.returnValue(errors); | ||
expect(validate.validators.date(value, options)).toBe(errors); | ||
@@ -340,0 +330,0 @@ expect(spy).toHaveBeenCalledWith(value, {foo: "bar", dateOnly: true}); |
@@ -75,3 +75,3 @@ describe('validators.equality', function() { | ||
, other = {bar: "foo"} | ||
, comparator = jasmine.createSpy("comparator").andReturn(true) | ||
, comparator = jasmine.createSpy("comparator").and.returnValue(true) | ||
, attributes = {complex: complex, other: other} | ||
@@ -95,5 +95,5 @@ , constraints = { | ||
comparator.andReturn(false); | ||
comparator.and.returnValue(false); | ||
expect(validate(attributes, constraints)).toBeDefined(); | ||
}); | ||
}); |
@@ -158,3 +158,3 @@ describe('validator.length', function() { | ||
it("supports default options", function() { | ||
var tokenizer = jasmine.createSpy("tokenizer").andReturn({length: 3}); | ||
var tokenizer = jasmine.createSpy("tokenizer").and.returnValue({length: 3}); | ||
validate.validators.length.options = { | ||
@@ -161,0 +161,0 @@ minimum: 10, |
@@ -1,2 +0,2 @@ | ||
// jasmine-promise 0.1.0 | ||
// jasmine-promise 0.2.0 | ||
// (c) 2014-2015 Nicklas Ansman | ||
@@ -11,16 +11,17 @@ // jasmine-promise may be freely distributed under the MIT license. | ||
if (!promise || typeof promise.then !== "function") | ||
if (!promise || typeof promise.then !== "function") { | ||
throw new Error("Got non promise back"); | ||
} | ||
if (!done) { | ||
var complete = false; | ||
done = function() { complete = true; }; | ||
waitsFor(function() { return complete; }); | ||
var error = jasmine.createSpy("errorHandler").and.callFake(function(msg) { | ||
expect(msg || "Unknown error").not.toBeDefined(); | ||
}); | ||
function success() { | ||
expect(error).not.toHaveBeenCalled(); | ||
} | ||
promise.then(undefined, function(error) { | ||
expect(error || "Unknown error").not.toBeDefined(); | ||
}).then(done); | ||
promise.then(undefined, error).then(success).then(done); | ||
}); | ||
}; | ||
})(); |
@@ -0,19 +1,836 @@ | ||
/** | ||
* @preserve XDate v0.8 | ||
* Docs & Licensing: http://arshaw.com/xdate/ | ||
*/ | ||
/* | ||
XDate v0.8 | ||
Docs & Licensing: http://arshaw.com/xdate/ | ||
*/ | ||
var XDate=function(g,n,A,p){function f(){var a=this instanceof f?this:new f,c=arguments,b=c.length,d;typeof c[b-1]=="boolean"&&(d=c[--b],c=q(c,0,b));if(b)if(b==1)if(b=c[0],b instanceof g||typeof b=="number")a[0]=new g(+b);else if(b instanceof f){var c=a,h=new g(+b[0]);if(l(b))h.toString=v;c[0]=h}else{if(typeof b=="string"){a[0]=new g(0);a:{for(var c=b,b=d||!1,h=f.parsers,w=0,e;w<h.length;w++)if(e=h[w](c,b,a)){a=e;break a}a[0]=new g(c)}}}else a[0]=new g(m.apply(g,c)),d||(a[0]=r(a[0]));else a[0]=new g; | ||
typeof d=="boolean"&&B(a,d);return a}function l(a){return a[0].toString===v}function B(a,c,b){if(c){if(!l(a))b&&(a[0]=new g(m(a[0].getFullYear(),a[0].getMonth(),a[0].getDate(),a[0].getHours(),a[0].getMinutes(),a[0].getSeconds(),a[0].getMilliseconds()))),a[0].toString=v}else l(a)&&(a[0]=b?r(a[0]):new g(+a[0]));return a}function C(a,c,b,d,h){var e=k(j,a[0],h),a=k(D,a[0],h),h=!1;d.length==2&&typeof d[1]=="boolean"&&(h=d[1],d=[b]);b=c==1?(b%12+12)%12:e(1);a(c,d);h&&e(1)!=b&&(a(1,[e(1)-1]),a(2,[E(e(0), | ||
e(1))]))}function F(a,c,b,d){var b=Number(b),h=n.floor(b);a["set"+o[c]](a["get"+o[c]]()+h,d||!1);h!=b&&c<6&&F(a,c+1,(b-h)*G[c],d)}function H(a,c,b){var a=a.clone().setUTCMode(!0,!0),c=f(c).setUTCMode(!0,!0),d=0;if(b==0||b==1){for(var h=6;h>=b;h--)d/=G[h],d+=j(c,!1,h)-j(a,!1,h);b==1&&(d+=(c.getFullYear()-a.getFullYear())*12)}else b==2?(b=a.toDate().setUTCHours(0,0,0,0),d=c.toDate().setUTCHours(0,0,0,0),d=n.round((d-b)/864E5)+(c-d-(a-b))/864E5):d=(c-a)/[36E5,6E4,1E3,1][b-3];return d}function s(a){var c= | ||
a(0),b=a(1),d=a(2),a=new g(m(c,b,d)),c=t(I(c,b,d));return n.floor(n.round((a-c)/864E5)/7)+1}function I(a,c,b){c=new g(m(a,c,b));if(c<t(a))return a-1;else if(c>=t(a+1))return a+1;return a}function t(a){a=new g(m(a,0,4));a.setUTCDate(a.getUTCDate()-(a.getUTCDay()+6)%7);return a}function J(a,c,b,d){var h=k(j,a,d),e=k(D,a,d);b===p&&(b=I(h(0),h(1),h(2)));b=t(b);d||(b=r(b));a.setTime(+b);e(2,[h(2)+(c-1)*7])}function K(a,c,b,d,h){var e=f.locales,g=e[f.defaultLocale]||{},i=k(j,a,h),b=(typeof b=="string"? | ||
e[b]:b)||{};return x(a,c,function(a){if(d)for(var b=(a==7?2:a)-1;b>=0;b--)d.push(i(b));return i(a)},function(a){return b[a]||g[a]},h)}function x(a,c,b,d,e){for(var f,g,i="";f=c.match(N);){i+=c.substr(0,f.index);if(f[1]){g=i;for(var i=a,j=f[1],l=b,m=d,n=e,k=j.length,o=void 0,q="";k>0;)o=O(i,j.substr(0,k),l,m,n),o!==p?(q+=o,j=j.substr(k),k=j.length):k--;i=g+(q+j)}else f[3]?(g=x(a,f[4],b,d,e),parseInt(g.replace(/\D/g,""),10)&&(i+=g)):i+=f[7]||"'";c=c.substr(f.index+f[0].length)}return i+c}function O(a, | ||
c,b,d,e){var g=f.formatters[c];if(typeof g=="string")return x(a,g,b,d,e);else if(typeof g=="function")return g(a,e||!1,d);switch(c){case "fff":return i(b(6),3);case "s":return b(5);case "ss":return i(b(5));case "m":return b(4);case "mm":return i(b(4));case "h":return b(3)%12||12;case "hh":return i(b(3)%12||12);case "H":return b(3);case "HH":return i(b(3));case "d":return b(2);case "dd":return i(b(2));case "ddd":return d("dayNamesShort")[b(7)]||"";case "dddd":return d("dayNames")[b(7)]||"";case "M":return b(1)+ | ||
1;case "MM":return i(b(1)+1);case "MMM":return d("monthNamesShort")[b(1)]||"";case "MMMM":return d("monthNames")[b(1)]||"";case "yy":return(b(0)+"").substring(2);case "yyyy":return b(0);case "t":return u(b,d).substr(0,1).toLowerCase();case "tt":return u(b,d).toLowerCase();case "T":return u(b,d).substr(0,1);case "TT":return u(b,d);case "z":case "zz":case "zzz":return e?c="Z":(d=a.getTimezoneOffset(),a=d<0?"+":"-",b=n.floor(n.abs(d)/60),d=n.abs(d)%60,e=b,c=="zz"?e=i(b):c=="zzz"&&(e=i(b)+":"+i(d)),c= | ||
a+e),c;case "w":return s(b);case "ww":return i(s(b));case "S":return c=b(2),c>10&&c<20?"th":["st","nd","rd"][c%10-1]||"th"}}function u(a,c){return a(3)<12?c("amDesignator"):c("pmDesignator")}function y(a){return!isNaN(+a[0])}function j(a,c,b){return a["get"+(c?"UTC":"")+o[b]]()}function D(a,c,b,d){a["set"+(c?"UTC":"")+o[b]].apply(a,d)}function r(a){return new g(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds())}function E(a, | ||
c){return 32-(new g(m(a,c,32))).getUTCDate()}function z(a){return function(){return a.apply(p,[this].concat(q(arguments)))}}function k(a){var c=q(arguments,1);return function(){return a.apply(p,c.concat(q(arguments)))}}function q(a,c,b){return A.prototype.slice.call(a,c||0,b===p?a.length:b)}function L(a,c){for(var b=0;b<a.length;b++)c(a[b],b)}function i(a,c){c=c||2;for(a+="";a.length<c;)a="0"+a;return a}var o="FullYear,Month,Date,Hours,Minutes,Seconds,Milliseconds,Day,Year".split(","),M=["Years", | ||
"Months","Days"],G=[12,31,24,60,60,1E3,1],N=/(([a-zA-Z])\2*)|(\((('.*?'|\(.*?\)|.)*?)\))|('(.*?)')/,m=g.UTC,v=g.prototype.toUTCString,e=f.prototype;e.length=1;e.splice=A.prototype.splice;e.getUTCMode=z(l);e.setUTCMode=z(B);e.getTimezoneOffset=function(){return l(this)?0:this[0].getTimezoneOffset()};L(o,function(a,c){e["get"+a]=function(){return j(this[0],l(this),c)};c!=8&&(e["getUTC"+a]=function(){return j(this[0],!0,c)});c!=7&&(e["set"+a]=function(a){C(this,c,a,arguments,l(this));return this},c!= | ||
8&&(e["setUTC"+a]=function(a){C(this,c,a,arguments,!0);return this},e["add"+(M[c]||a)]=function(a,d){F(this,c,a,d);return this},e["diff"+(M[c]||a)]=function(a){return H(this,a,c)}))});e.getWeek=function(){return s(k(j,this,!1))};e.getUTCWeek=function(){return s(k(j,this,!0))};e.setWeek=function(a,c){J(this,a,c,!1);return this};e.setUTCWeek=function(a,c){J(this,a,c,!0);return this};e.addWeeks=function(a){return this.addDays(Number(a)*7)};e.diffWeeks=function(a){return H(this,a,2)/7};f.parsers=[function(a, | ||
c,b){if(a=a.match(/^(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/)){var d=new g(m(a[1],a[3]?a[3]-1:0,a[5]||1,a[7]||0,a[8]||0,a[10]||0,a[12]?Number("0."+a[12])*1E3:0));a[13]?a[14]&&d.setUTCMinutes(d.getUTCMinutes()+(a[15]=="-"?1:-1)*(Number(a[16])*60+(a[18]?Number(a[18]):0))):c||(d=r(d));return b.setTime(+d)}}];f.parse=function(a){return+f(""+a)};e.toString=function(a,c,b){return a===p||!y(this)?this[0].toString():K(this,a,c,b,l(this))}; | ||
e.toUTCString=e.toGMTString=function(a,c,b){return a===p||!y(this)?this[0].toUTCString():K(this,a,c,b,!0)};e.toISOString=function(){return this.toUTCString("yyyy-MM-dd'T'HH:mm:ss(.fff)zzz")};f.defaultLocale="";f.locales={"":{monthNames:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthNamesShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),dayNames:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),dayNamesShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","), | ||
amDesignator:"AM",pmDesignator:"PM"}};f.formatters={i:"yyyy-MM-dd'T'HH:mm:ss(.fff)",u:"yyyy-MM-dd'T'HH:mm:ss(.fff)zzz"};L("getTime,valueOf,toDateString,toTimeString,toLocaleString,toLocaleDateString,toLocaleTimeString,toJSON".split(","),function(a){e[a]=function(){return this[0][a]()}});e.setTime=function(a){this[0].setTime(a);return this};e.valid=z(y);e.clone=function(){return new f(this)};e.clearTime=function(){return this.setHours(0,0,0,0)};e.toDate=function(){return new g(+this[0])};f.now=function(){return+new g}; | ||
f.today=function(){return(new f).clearTime()};f.UTC=m;f.getDaysInMonth=E;if(typeof module!=="undefined"&&module.exports)module.exports=f;typeof define==="function"&&define.amd&&define([],function(){return f});return f}(Date,Math,Array); | ||
* Internal Architecture | ||
* --------------------- | ||
* An XDate wraps a native Date. The native Date is stored in the '0' property of the object. | ||
* UTC-mode is determined by whether the internal native Date's toString method is set to | ||
* Date.prototype.toUTCString (see getUTCMode). | ||
* | ||
*/ | ||
var XDate = (function(Date, Math, Array, undefined) { | ||
/** @const */ var FULLYEAR = 0; | ||
/** @const */ var MONTH = 1; | ||
/** @const */ var DATE = 2; | ||
/** @const */ var HOURS = 3; | ||
/** @const */ var MINUTES = 4; | ||
/** @const */ var SECONDS = 5; | ||
/** @const */ var MILLISECONDS = 6; | ||
/** @const */ var DAY = 7; | ||
/** @const */ var YEAR = 8; | ||
/** @const */ var WEEK = 9; | ||
/** @const */ var DAY_MS = 86400000; | ||
var ISO_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss(.fff)"; | ||
var ISO_FORMAT_STRING_TZ = ISO_FORMAT_STRING + "zzz"; | ||
var methodSubjects = [ | ||
'FullYear', // 0 | ||
'Month', // 1 | ||
'Date', // 2 | ||
'Hours', // 3 | ||
'Minutes', // 4 | ||
'Seconds', // 5 | ||
'Milliseconds', // 6 | ||
'Day', // 7 | ||
'Year' // 8 | ||
]; | ||
var subjectPlurals = [ | ||
'Years', // 0 | ||
'Months', // 1 | ||
'Days' // 2 | ||
]; | ||
var unitsWithin = [ | ||
12, // months in year | ||
31, // days in month (sort of) | ||
24, // hours in day | ||
60, // minutes in hour | ||
60, // seconds in minute | ||
1000, // milliseconds in second | ||
1 // | ||
]; | ||
var formatStringRE = new RegExp( | ||
"(([a-zA-Z])\\2*)|" + // 1, 2 | ||
"(\\(" + "(('.*?'|\\(.*?\\)|.)*?)" + "\\))|" + // 3, 4, 5 (allows for 1 level of inner quotes or parens) | ||
"('(.*?)')" // 6, 7 | ||
); | ||
var UTC = Date.UTC; | ||
var toUTCString = Date.prototype.toUTCString; | ||
var proto = XDate.prototype; | ||
// This makes an XDate look pretty in Firebug and Web Inspector. | ||
// It makes an XDate seem array-like, and displays [ <internal-date>.toString() ] | ||
proto.length = 1; | ||
proto.splice = Array.prototype.splice; | ||
/* Constructor | ||
---------------------------------------------------------------------------------*/ | ||
// TODO: in future, I'd change signature for the constructor regarding the `true` utc-mode param. ~ashaw | ||
// I'd move the boolean to be the *first* argument. Still optional. Seems cleaner. | ||
// I'd remove it from the `xdate`, `nativeDate`, and `milliseconds` constructors. | ||
// (because you can simply call .setUTCMode(true) after) | ||
// And I'd only leave it for the y/m/d/h/m/s/m and `dateString` constructors | ||
// (because those are the only constructors that need it for DST-gap data-loss reasons) | ||
// Should do this for 1.0 | ||
function XDate() { | ||
return init( | ||
(this instanceof XDate) ? this : new XDate(), | ||
arguments | ||
); | ||
} | ||
function init(xdate, args) { | ||
var len = args.length; | ||
var utcMode; | ||
if (isBoolean(args[len-1])) { | ||
utcMode = args[--len]; | ||
args = slice(args, 0, len); | ||
} | ||
if (!len) { | ||
xdate[0] = new Date(); | ||
} | ||
else if (len == 1) { | ||
var arg = args[0]; | ||
if (arg instanceof Date || isNumber(arg)) { | ||
xdate[0] = new Date(+arg); | ||
} | ||
else if (arg instanceof XDate) { | ||
xdate[0] = _clone(arg); | ||
} | ||
else if (isString(arg)) { | ||
xdate[0] = new Date(0); | ||
xdate = parse(arg, utcMode || false, xdate); | ||
} | ||
} | ||
else { | ||
xdate[0] = new Date(UTC.apply(Date, args)); | ||
if (!utcMode) { | ||
xdate[0] = coerceToLocal(xdate[0]); | ||
} | ||
} | ||
if (isBoolean(utcMode)) { | ||
setUTCMode(xdate, utcMode); | ||
} | ||
return xdate; | ||
} | ||
/* UTC Mode Methods | ||
---------------------------------------------------------------------------------*/ | ||
proto.getUTCMode = methodize(getUTCMode); | ||
function getUTCMode(xdate) { | ||
return xdate[0].toString === toUTCString; | ||
}; | ||
proto.setUTCMode = methodize(setUTCMode); | ||
function setUTCMode(xdate, utcMode, doCoercion) { | ||
if (utcMode) { | ||
if (!getUTCMode(xdate)) { | ||
if (doCoercion) { | ||
xdate[0] = coerceToUTC(xdate[0]); | ||
} | ||
xdate[0].toString = toUTCString; | ||
} | ||
}else{ | ||
if (getUTCMode(xdate)) { | ||
if (doCoercion) { | ||
xdate[0] = coerceToLocal(xdate[0]); | ||
}else{ | ||
xdate[0] = new Date(+xdate[0]); | ||
} | ||
// toString will have been cleared | ||
} | ||
} | ||
return xdate; // for chaining | ||
} | ||
proto.getTimezoneOffset = function() { | ||
if (getUTCMode(this)) { | ||
return 0; | ||
}else{ | ||
return this[0].getTimezoneOffset(); | ||
} | ||
}; | ||
/* get / set / add / diff Methods (except for week-related) | ||
---------------------------------------------------------------------------------*/ | ||
each(methodSubjects, function(subject, fieldIndex) { | ||
proto['get' + subject] = function() { | ||
return _getField(this[0], getUTCMode(this), fieldIndex); | ||
}; | ||
if (fieldIndex != YEAR) { // because there is no getUTCYear | ||
proto['getUTC' + subject] = function() { | ||
return _getField(this[0], true, fieldIndex); | ||
}; | ||
} | ||
if (fieldIndex != DAY) { // because there is no setDay or setUTCDay | ||
// and the add* and diff* methods use DATE instead | ||
proto['set' + subject] = function(value) { | ||
_set(this, fieldIndex, value, arguments, getUTCMode(this)); | ||
return this; // for chaining | ||
}; | ||
if (fieldIndex != YEAR) { // because there is no setUTCYear | ||
// and the add* and diff* methods use FULLYEAR instead | ||
proto['setUTC' + subject] = function(value) { | ||
_set(this, fieldIndex, value, arguments, true); | ||
return this; // for chaining | ||
}; | ||
proto['add' + (subjectPlurals[fieldIndex] || subject)] = function(delta, preventOverflow) { | ||
_add(this, fieldIndex, delta, preventOverflow); | ||
return this; // for chaining | ||
}; | ||
proto['diff' + (subjectPlurals[fieldIndex] || subject)] = function(otherDate) { | ||
return _diff(this, otherDate, fieldIndex); | ||
}; | ||
} | ||
} | ||
}); | ||
function _set(xdate, fieldIndex, value, args, useUTC) { | ||
var getField = curry(_getField, xdate[0], useUTC); | ||
var setField = curry(_setField, xdate[0], useUTC); | ||
var expectedMonth; | ||
var preventOverflow = false; | ||
if (args.length == 2 && isBoolean(args[1])) { | ||
preventOverflow = args[1]; | ||
args = [ value ]; | ||
} | ||
if (fieldIndex == MONTH) { | ||
expectedMonth = (value % 12 + 12) % 12; | ||
}else{ | ||
expectedMonth = getField(MONTH); | ||
} | ||
setField(fieldIndex, args); | ||
if (preventOverflow && getField(MONTH) != expectedMonth) { | ||
setField(MONTH, [ getField(MONTH) - 1 ]); | ||
setField(DATE, [ getDaysInMonth(getField(FULLYEAR), getField(MONTH)) ]); | ||
} | ||
} | ||
function _add(xdate, fieldIndex, delta, preventOverflow) { | ||
delta = Number(delta); | ||
var intDelta = Math.floor(delta); | ||
xdate['set' + methodSubjects[fieldIndex]]( | ||
xdate['get' + methodSubjects[fieldIndex]]() + intDelta, | ||
preventOverflow || false | ||
); | ||
if (intDelta != delta && fieldIndex < MILLISECONDS) { | ||
_add(xdate, fieldIndex+1, (delta-intDelta)*unitsWithin[fieldIndex], preventOverflow); | ||
} | ||
} | ||
function _diff(xdate1, xdate2, fieldIndex) { // fieldIndex=FULLYEAR is for years, fieldIndex=DATE is for days | ||
xdate1 = xdate1.clone().setUTCMode(true, true); | ||
xdate2 = XDate(xdate2).setUTCMode(true, true); | ||
var v = 0; | ||
if (fieldIndex == FULLYEAR || fieldIndex == MONTH) { | ||
for (var i=MILLISECONDS, methodName; i>=fieldIndex; i--) { | ||
v /= unitsWithin[i]; | ||
v += _getField(xdate2, false, i) - _getField(xdate1, false, i); | ||
} | ||
if (fieldIndex == MONTH) { | ||
v += (xdate2.getFullYear() - xdate1.getFullYear()) * 12; | ||
} | ||
} | ||
else if (fieldIndex == DATE) { | ||
var clear1 = xdate1.toDate().setUTCHours(0, 0, 0, 0); // returns an ms value | ||
var clear2 = xdate2.toDate().setUTCHours(0, 0, 0, 0); // returns an ms value | ||
v = Math.round((clear2 - clear1) / DAY_MS) + ((xdate2 - clear2) - (xdate1 - clear1)) / DAY_MS; | ||
} | ||
else { | ||
v = (xdate2 - xdate1) / [ | ||
3600000, // milliseconds in hour | ||
60000, // milliseconds in minute | ||
1000, // milliseconds in second | ||
1 // | ||
][fieldIndex - 3]; | ||
} | ||
return v; | ||
} | ||
/* Week Methods | ||
---------------------------------------------------------------------------------*/ | ||
proto.getWeek = function() { | ||
return _getWeek(curry(_getField, this, false)); | ||
}; | ||
proto.getUTCWeek = function() { | ||
return _getWeek(curry(_getField, this, true)); | ||
}; | ||
proto.setWeek = function(n, year) { | ||
_setWeek(this, n, year, false); | ||
return this; // for chaining | ||
}; | ||
proto.setUTCWeek = function(n, year) { | ||
_setWeek(this, n, year, true); | ||
return this; // for chaining | ||
}; | ||
proto.addWeeks = function(delta) { | ||
return this.addDays(Number(delta) * 7); | ||
}; | ||
proto.diffWeeks = function(otherDate) { | ||
return _diff(this, otherDate, DATE) / 7; | ||
}; | ||
function _getWeek(getField) { | ||
return getWeek(getField(FULLYEAR), getField(MONTH), getField(DATE)); | ||
} | ||
function getWeek(year, month, date) { | ||
var d = new Date(UTC(year, month, date)); | ||
var week1 = getWeek1( | ||
getWeekYear(year, month, date) | ||
); | ||
return Math.floor(Math.round((d - week1) / DAY_MS) / 7) + 1; | ||
} | ||
function getWeekYear(year, month, date) { // get the year that the date's week # belongs to | ||
var d = new Date(UTC(year, month, date)); | ||
if (d < getWeek1(year)) { | ||
return year - 1; | ||
} | ||
else if (d >= getWeek1(year + 1)) { | ||
return year + 1; | ||
} | ||
return year; | ||
} | ||
function getWeek1(year) { // returns Date of first week of year, in UTC | ||
var d = new Date(UTC(year, 0, 4)); | ||
d.setUTCDate(d.getUTCDate() - (d.getUTCDay() + 6) % 7); // make it Monday of the week | ||
return d; | ||
} | ||
function _setWeek(xdate, n, year, useUTC) { | ||
var getField = curry(_getField, xdate, useUTC); | ||
var setField = curry(_setField, xdate, useUTC); | ||
if (year === undefined) { | ||
year = getWeekYear( | ||
getField(FULLYEAR), | ||
getField(MONTH), | ||
getField(DATE) | ||
); | ||
} | ||
var week1 = getWeek1(year); | ||
if (!useUTC) { | ||
week1 = coerceToLocal(week1); | ||
} | ||
xdate.setTime(+week1); | ||
setField(DATE, [ getField(DATE) + (n-1) * 7 ]); // would have used xdate.addUTCWeeks :( | ||
// n-1 because n is 1-based | ||
} | ||
/* Parsing | ||
---------------------------------------------------------------------------------*/ | ||
XDate.parsers = [ | ||
parseISO | ||
]; | ||
XDate.parse = function(str) { | ||
return +XDate(''+str); | ||
}; | ||
function parse(str, utcMode, xdate) { | ||
var parsers = XDate.parsers; | ||
var i = 0; | ||
var res; | ||
for (; i<parsers.length; i++) { | ||
res = parsers[i](str, utcMode, xdate); | ||
if (res) { | ||
return res; | ||
} | ||
} | ||
xdate[0] = new Date(str); | ||
return xdate; | ||
} | ||
function parseISO(str, utcMode, xdate) { | ||
var m = str.match(/^(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/); | ||
if (m) { | ||
var d = new Date(UTC( | ||
m[1], | ||
m[3] ? m[3] - 1 : 0, | ||
m[5] || 1, | ||
m[7] || 0, | ||
m[8] || 0, | ||
m[10] || 0, | ||
m[12] ? Number('0.' + m[12]) * 1000 : 0 | ||
)); | ||
if (m[13]) { // has gmt offset or Z | ||
if (m[14]) { // has gmt offset | ||
d.setUTCMinutes( | ||
d.getUTCMinutes() + | ||
(m[15] == '-' ? 1 : -1) * (Number(m[16]) * 60 + (m[18] ? Number(m[18]) : 0)) | ||
); | ||
} | ||
}else{ // no specified timezone | ||
if (!utcMode) { | ||
d = coerceToLocal(d); | ||
} | ||
} | ||
return xdate.setTime(+d); | ||
} | ||
} | ||
/* Formatting | ||
---------------------------------------------------------------------------------*/ | ||
proto.toString = function(formatString, settings, uniqueness) { | ||
if (formatString === undefined || !valid(this)) { | ||
return this[0].toString(); // already accounts for utc-mode (might be toUTCString) | ||
}else{ | ||
return format(this, formatString, settings, uniqueness, getUTCMode(this)); | ||
} | ||
}; | ||
proto.toUTCString = proto.toGMTString = function(formatString, settings, uniqueness) { | ||
if (formatString === undefined || !valid(this)) { | ||
return this[0].toUTCString(); | ||
}else{ | ||
return format(this, formatString, settings, uniqueness, true); | ||
} | ||
}; | ||
proto.toISOString = function() { | ||
return this.toUTCString(ISO_FORMAT_STRING_TZ); | ||
}; | ||
XDate.defaultLocale = ''; | ||
XDate.locales = { | ||
'': { | ||
monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'], | ||
monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'], | ||
dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], | ||
dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'], | ||
amDesignator: 'AM', | ||
pmDesignator: 'PM' | ||
} | ||
}; | ||
XDate.formatters = { | ||
i: ISO_FORMAT_STRING, | ||
u: ISO_FORMAT_STRING_TZ | ||
}; | ||
function format(xdate, formatString, settings, uniqueness, useUTC) { | ||
var locales = XDate.locales; | ||
var defaultLocaleSettings = locales[XDate.defaultLocale] || {}; | ||
var getField = curry(_getField, xdate, useUTC); | ||
settings = (isString(settings) ? locales[settings] : settings) || {}; | ||
function getSetting(name) { | ||
return settings[name] || defaultLocaleSettings[name]; | ||
} | ||
function getFieldAndTrace(fieldIndex) { | ||
if (uniqueness) { | ||
var i = (fieldIndex == DAY ? DATE : fieldIndex) - 1; | ||
for (; i>=0; i--) { | ||
uniqueness.push(getField(i)); | ||
} | ||
} | ||
return getField(fieldIndex); | ||
} | ||
return _format(xdate, formatString, getFieldAndTrace, getSetting, useUTC); | ||
} | ||
function _format(xdate, formatString, getField, getSetting, useUTC) { | ||
var m; | ||
var subout; | ||
var out = ''; | ||
while (m = formatString.match(formatStringRE)) { | ||
out += formatString.substr(0, m.index); | ||
if (m[1]) { // consecutive alphabetic characters | ||
out += processTokenString(xdate, m[1], getField, getSetting, useUTC); | ||
} | ||
else if (m[3]) { // parenthesis | ||
subout = _format(xdate, m[4], getField, getSetting, useUTC); | ||
if (parseInt(subout.replace(/\D/g, ''), 10)) { // if any of the numbers are non-zero. or no numbers at all | ||
out += subout; | ||
} | ||
} | ||
else { // else if (m[6]) { // single quotes | ||
out += m[7] || "'"; // if inner is blank, meaning 2 consecutive quotes = literal single quote | ||
} | ||
formatString = formatString.substr(m.index + m[0].length); | ||
} | ||
return out + formatString; | ||
} | ||
function processTokenString(xdate, tokenString, getField, getSetting, useUTC) { | ||
var end = tokenString.length; | ||
var replacement; | ||
var out = ''; | ||
while (end > 0) { | ||
replacement = getTokenReplacement(xdate, tokenString.substr(0, end), getField, getSetting, useUTC); | ||
if (replacement !== undefined) { | ||
out += replacement; | ||
tokenString = tokenString.substr(end); | ||
end = tokenString.length; | ||
}else{ | ||
end--; | ||
} | ||
} | ||
return out + tokenString; | ||
} | ||
function getTokenReplacement(xdate, token, getField, getSetting, useUTC) { | ||
var formatter = XDate.formatters[token]; | ||
if (isString(formatter)) { | ||
return _format(xdate, formatter, getField, getSetting, useUTC); | ||
} | ||
else if (isFunction(formatter)) { | ||
return formatter(xdate, useUTC || false, getSetting); | ||
} | ||
switch (token) { | ||
case 'fff' : return zeroPad(getField(MILLISECONDS), 3); | ||
case 's' : return getField(SECONDS); | ||
case 'ss' : return zeroPad(getField(SECONDS)); | ||
case 'm' : return getField(MINUTES); | ||
case 'mm' : return zeroPad(getField(MINUTES)); | ||
case 'h' : return getField(HOURS) % 12 || 12; | ||
case 'hh' : return zeroPad(getField(HOURS) % 12 || 12); | ||
case 'H' : return getField(HOURS); | ||
case 'HH' : return zeroPad(getField(HOURS)); | ||
case 'd' : return getField(DATE); | ||
case 'dd' : return zeroPad(getField(DATE)); | ||
case 'ddd' : return getSetting('dayNamesShort')[getField(DAY)] || ''; | ||
case 'dddd' : return getSetting('dayNames')[getField(DAY)] || ''; | ||
case 'M' : return getField(MONTH) + 1; | ||
case 'MM' : return zeroPad(getField(MONTH) + 1); | ||
case 'MMM' : return getSetting('monthNamesShort')[getField(MONTH)] || ''; | ||
case 'MMMM' : return getSetting('monthNames')[getField(MONTH)] || ''; | ||
case 'yy' : return (getField(FULLYEAR)+'').substring(2); | ||
case 'yyyy' : return getField(FULLYEAR); | ||
case 't' : return _getDesignator(getField, getSetting).substr(0, 1).toLowerCase(); | ||
case 'tt' : return _getDesignator(getField, getSetting).toLowerCase(); | ||
case 'T' : return _getDesignator(getField, getSetting).substr(0, 1); | ||
case 'TT' : return _getDesignator(getField, getSetting); | ||
case 'z' : | ||
case 'zz' : | ||
case 'zzz' : return useUTC ? 'Z' : _getTZString(xdate, token); | ||
case 'w' : return _getWeek(getField); | ||
case 'ww' : return zeroPad(_getWeek(getField)); | ||
case 'S' : | ||
var d = getField(DATE); | ||
if (d > 10 && d < 20) return 'th'; | ||
return ['st', 'nd', 'rd'][d % 10 - 1] || 'th'; | ||
} | ||
} | ||
function _getTZString(xdate, token) { | ||
var tzo = xdate.getTimezoneOffset(); | ||
var sign = tzo < 0 ? '+' : '-'; | ||
var hours = Math.floor(Math.abs(tzo) / 60); | ||
var minutes = Math.abs(tzo) % 60; | ||
var out = hours; | ||
if (token == 'zz') { | ||
out = zeroPad(hours); | ||
} | ||
else if (token == 'zzz') { | ||
out = zeroPad(hours) + ':' + zeroPad(minutes); | ||
} | ||
return sign + out; | ||
} | ||
function _getDesignator(getField, getSetting) { | ||
return getField(HOURS) < 12 ? getSetting('amDesignator') : getSetting('pmDesignator'); | ||
} | ||
/* Misc Methods | ||
---------------------------------------------------------------------------------*/ | ||
each( | ||
[ // other getters | ||
'getTime', | ||
'valueOf', | ||
'toDateString', | ||
'toTimeString', | ||
'toLocaleString', | ||
'toLocaleDateString', | ||
'toLocaleTimeString', | ||
'toJSON' | ||
], | ||
function(methodName) { | ||
proto[methodName] = function() { | ||
return this[0][methodName](); | ||
}; | ||
} | ||
); | ||
proto.setTime = function(t) { | ||
this[0].setTime(t); | ||
return this; // for chaining | ||
}; | ||
proto.valid = methodize(valid); | ||
function valid(xdate) { | ||
return !isNaN(+xdate[0]); | ||
} | ||
proto.clone = function() { | ||
return new XDate(this); | ||
}; | ||
proto.clearTime = function() { | ||
return this.setHours(0, 0, 0, 0); // will return an XDate for chaining | ||
}; | ||
proto.toDate = function() { | ||
return new Date(+this[0]); | ||
}; | ||
/* Misc Class Methods | ||
---------------------------------------------------------------------------------*/ | ||
XDate.now = function() { | ||
return +new Date(); | ||
}; | ||
XDate.today = function() { | ||
return new XDate().clearTime(); | ||
}; | ||
XDate.UTC = UTC; | ||
XDate.getDaysInMonth = getDaysInMonth; | ||
/* Internal Utilities | ||
---------------------------------------------------------------------------------*/ | ||
function _clone(xdate) { // returns the internal Date object that should be used | ||
var d = new Date(+xdate[0]); | ||
if (getUTCMode(xdate)) { | ||
d.toString = toUTCString; | ||
} | ||
return d; | ||
} | ||
function _getField(d, useUTC, fieldIndex) { | ||
return d['get' + (useUTC ? 'UTC' : '') + methodSubjects[fieldIndex]](); | ||
} | ||
function _setField(d, useUTC, fieldIndex, args) { | ||
d['set' + (useUTC ? 'UTC' : '') + methodSubjects[fieldIndex]].apply(d, args); | ||
} | ||
/* Date Math Utilities | ||
---------------------------------------------------------------------------------*/ | ||
function coerceToUTC(date) { | ||
return new Date(UTC( | ||
date.getFullYear(), | ||
date.getMonth(), | ||
date.getDate(), | ||
date.getHours(), | ||
date.getMinutes(), | ||
date.getSeconds(), | ||
date.getMilliseconds() | ||
)); | ||
} | ||
function coerceToLocal(date) { | ||
return new Date( | ||
date.getUTCFullYear(), | ||
date.getUTCMonth(), | ||
date.getUTCDate(), | ||
date.getUTCHours(), | ||
date.getUTCMinutes(), | ||
date.getUTCSeconds(), | ||
date.getUTCMilliseconds() | ||
); | ||
} | ||
function getDaysInMonth(year, month) { | ||
return 32 - new Date(UTC(year, month, 32)).getUTCDate(); | ||
} | ||
/* General Utilities | ||
---------------------------------------------------------------------------------*/ | ||
function methodize(f) { | ||
return function() { | ||
return f.apply(undefined, [this].concat(slice(arguments))); | ||
}; | ||
} | ||
function curry(f) { | ||
var firstArgs = slice(arguments, 1); | ||
return function() { | ||
return f.apply(undefined, firstArgs.concat(slice(arguments))); | ||
}; | ||
} | ||
function slice(a, start, end) { | ||
return Array.prototype.slice.call( | ||
a, | ||
start || 0, // start and end cannot be undefined for IE | ||
end===undefined ? a.length : end | ||
); | ||
} | ||
function each(a, f) { | ||
for (var i=0; i<a.length; i++) { | ||
f(a[i], i); | ||
}; | ||
} | ||
function isString(arg) { | ||
return typeof arg == 'string'; | ||
} | ||
function isNumber(arg) { | ||
return typeof arg == 'number'; | ||
} | ||
function isBoolean(arg) { | ||
return typeof arg == 'boolean'; | ||
} | ||
function isFunction(arg) { | ||
return typeof arg == 'function'; | ||
} | ||
function zeroPad(n, len) { | ||
len = len || 2; | ||
n += ''; | ||
while (n.length < len) { | ||
n = '0' + n; | ||
} | ||
return n; | ||
} | ||
// Export for Node.js | ||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = XDate; | ||
} | ||
// AMD | ||
if (typeof define === 'function' && define.amd) { | ||
define([], function() { | ||
return XDate; | ||
}); | ||
} | ||
return XDate; | ||
})(Date, Math, Array); |
181
validate.js
@@ -1,2 +0,2 @@ | ||
// Validate.js 0.5.0 | ||
// Validate.js 0.6.0 | ||
// (c) 2013-2015 Nicklas Ansman, 2013 Wrapp | ||
@@ -7,3 +7,3 @@ // Validate.js may be freely distributed under the MIT license. | ||
(function(exports, module, define, require) { | ||
(function(exports, module, define) { | ||
"use strict"; | ||
@@ -34,6 +34,3 @@ | ||
var v = validate | ||
, root = this | ||
// Finds %{key} style patterns in the given string | ||
, FORMAT_REGEXP = /%\{([^\}]+)\}/g; | ||
var v = validate; | ||
@@ -54,11 +51,18 @@ // Copies over attributes from one or more sources to a single destination. | ||
v.extend(validate, { | ||
// Below is the dependencies that are used in validate.js | ||
// The constructor of the Promise implementation. | ||
// If you are using Q.js, RSVP or any other A+ compatible implementation | ||
// override this attribute to be the constructor of that promise. | ||
// Since jQuery promises aren't A+ compatible they won't work. | ||
Promise: typeof Promise !== "undefined" ? Promise : /* istanbul ignore next */ null, | ||
// If moment is used in node, browserify etc please set this attribute | ||
// like this: `validate.moment = require("moment"); | ||
moment: typeof moment !== "undefined" ? moment : /* istanbul ignore next */ null, | ||
XDate: typeof XDate !== "undefined" ? XDate : /* istanbul ignore next */ null, | ||
EMPTY_STRING_REGEXP: /^\s*$/, | ||
// This "class" is just a wrapper around a dictionary and is here to allow | ||
// you to differentiate between library errors and validation errors | ||
// when using promises. | ||
ValidationErrors: function(errors) { | ||
v.extend(this, errors); | ||
}, | ||
// Runs the validators specified by the constraints object. | ||
@@ -154,9 +158,6 @@ // Will return an array of the format: | ||
return v.Promise(function(resolve, reject) { | ||
return new v.Promise(function(resolve, reject) { | ||
v.waitForResults(results).then(function() { | ||
var errors = v.processValidationResults(results, options); | ||
if (errors) { | ||
if (!options.flatten) { | ||
errors = new v.ValidationErrors(errors); | ||
} | ||
reject(errors); | ||
@@ -170,2 +171,10 @@ } else { | ||
single: function(value, constraints, options) { | ||
options = v.extend({}, v.single.options, options, { | ||
flatten: true, | ||
fullMessages: false | ||
}); | ||
return v({single: value}, {single: constraints}, options); | ||
}, | ||
// Returns a promise that is resolved when all promises in the results array | ||
@@ -199,3 +208,3 @@ // are settled. The promise returned from this function is always resolved, | ||
}).then(undefined, v.error); | ||
}, v.Promise(function(r) { r(); })); // A resolved promise | ||
}, new v.Promise(function(r) { r(); })); // A resolved promise | ||
@@ -251,3 +260,3 @@ return promise.then(undefined, v.error); | ||
isPromise: function(p) { | ||
return !!p && typeof p.then === 'function'; | ||
return !!p && v.isFunction(p.then); | ||
}, | ||
@@ -319,7 +328,17 @@ | ||
// ``` | ||
format: function(str, vals) { | ||
return str.replace(FORMAT_REGEXP, function(m0, m1) { | ||
return String(vals[m1]); | ||
// If you want to write %{...} without having it replaced simply | ||
// prefix it with % like this `Foo: %%{foo}` and it will be returned | ||
// as `"Foo: %{foo}"` | ||
format: v.extend(function(str, vals) { | ||
return str.replace(v.format.FORMAT_REGEXP, function(m0, m1, m2) { | ||
if (m1 === '%') { | ||
return "%{" + m2 + "}"; | ||
} else { | ||
return String(vals[m2]); | ||
} | ||
}); | ||
}, | ||
}, { | ||
// Finds %{key} style patterns in the given string | ||
FORMAT_REGEXP: /(%?)%\{([^\}]+)\}/g | ||
}), | ||
@@ -521,97 +540,2 @@ // "Prettifies" the given string. | ||
// Returns a promise, should be called with the new operator. | ||
// The first argument will be called with two functions, the first for | ||
// resolving the promise and the second for rejecting it. | ||
// Supports (in order of precedence): | ||
// * EcmaScript 6 Promises | ||
// * RSVP | ||
// * when | ||
// * Q | ||
// | ||
// If no supported promises are detected an error is thrown. | ||
// A word of warning, only A+ style promises are supported. jQuery deferreds | ||
// are NOT supported. | ||
Promise: v.extend(function(callback) { | ||
var promise = v.Promise.nativePromise(callback) || | ||
v.Promise.RSVPPromise(callback) || | ||
v.Promise.whenPromise(callback) || | ||
v.Promise.QPromise(callback); | ||
if (!promise) { | ||
throw new Error("No promises could be detected"); | ||
} | ||
return promise; | ||
}, { | ||
nativePromise: function(callback) { | ||
var Promise_, module; | ||
if (typeof Promise !== "undefined") { | ||
Promise_ = Promise; | ||
} else { | ||
module = v.tryRequire("es6-promise"); | ||
if (module) { | ||
Promise_ = module.Promise; | ||
} | ||
} | ||
if (Promise_) { | ||
return new Promise_(callback); | ||
} | ||
}, | ||
RSVPPromise: function(callback) { | ||
var Promise, module; | ||
if (typeof RSVP !== "undefined") { | ||
Promise = RSVP.Promise; | ||
} else { | ||
module = v.tryRequire("rsvp"); | ||
if (module) { | ||
Promise = module.Promise; | ||
} | ||
} | ||
if (Promise) { | ||
return new Promise(callback); | ||
} | ||
}, | ||
whenPromise: function(callback) { | ||
var promise, module; | ||
if (typeof when !== "undefined") { | ||
promise = when.promise; | ||
} else { | ||
module = v.tryRequire("when"); | ||
if (module) { | ||
promise = module.promise; | ||
} | ||
} | ||
if (promise) { | ||
return promise(callback); | ||
} | ||
}, | ||
QPromise: function(callback) { | ||
var promise, module; | ||
if (typeof Q !== "undefined") { | ||
promise = Q.promise; | ||
} else { | ||
module = v.tryRequire("q"); | ||
if (module) { | ||
promise = module.promise; | ||
} | ||
} | ||
if (promise) { | ||
return promise(callback); | ||
} | ||
} | ||
}), | ||
tryRequire: function(moduleName) { | ||
if (!v.require) { | ||
return null; | ||
} | ||
try { | ||
return v.require(moduleName); | ||
} catch(e) { | ||
return null; | ||
} | ||
}, | ||
require: require, | ||
exposeModule: function(validate, root, exports, module, define) { | ||
@@ -804,9 +728,8 @@ if (exports) { | ||
parse: function(value, options) { | ||
if (v.isFunction(root.XDate)) { | ||
return new root.XDate(value, true).getTime(); | ||
if (v.isFunction(v.XDate)) { | ||
return new v.XDate(value, true).getTime(); | ||
} | ||
var moment = v.tryRequire("moment") || root.moment; | ||
if (v.isDefined(moment)) { | ||
return +moment.utc(value); | ||
if (v.isDefined(v.moment)) { | ||
return +v.moment.utc(value); | ||
} | ||
@@ -822,3 +745,3 @@ | ||
if (v.isFunction(root.XDate)) { | ||
if (v.isFunction(v.XDate)) { | ||
format = format || (options.dateOnly ? "yyyy-MM-dd" : "yyyy-MM-dd HH:mm:ss"); | ||
@@ -828,6 +751,5 @@ return new XDate(date, true).toString(format); | ||
var moment = v.tryRequire("moment") || root.moment; | ||
if (v.isDefined(moment)) { | ||
if (v.isDefined(v.moment)) { | ||
format = format || (options.dateOnly ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss"); | ||
return moment.utc(date).format(format); | ||
return v.moment.utc(date).format(format); | ||
} | ||
@@ -945,7 +867,6 @@ | ||
validate.exposeModule(validate, root, exports, module, define); | ||
validate.exposeModule(validate, this, exports, module, define); | ||
}).call(this, | ||
typeof exports !== 'undefined' ? /* istanbul ignore next */ exports : null, | ||
typeof module !== 'undefined' ? /* istanbul ignore next */ module : null, | ||
typeof define !== 'undefined' ? /* istanbul ignore next */ define : null, | ||
typeof require !== 'undefined' ? /* istanbul ignore next */ require : null); | ||
typeof define !== 'undefined' ? /* istanbul ignore next */ define : null); |
@@ -1,2 +0,2 @@ | ||
// validate.js 0.5.0 | ||
// validate.js 0.6.0 | ||
// http://validatejs.org/ | ||
@@ -6,3 +6,3 @@ // (c) 2013-2015 Nicklas Ansman, 2013 Wrapp | ||
(function(a,b,c,d){"use strict";var e=function(a,b,c){c=f.extend({},f.options,c);var d,g,h=f.runValidations(a,b,c);for(d in h)for(g in h[d])if(f.isPromise(h[d][g]))throw new Error("Use validate.async if you want support for promises");return e.processValidationResults(h,c)},f=e,g=this,h=/%\{([^\}]+)\}/g;f.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},f.extend(e,{EMPTY_STRING_REGEXP:/^\s*$/,ValidationErrors:function(a){f.extend(this,a)},runValidations:function(a,b,c){var d,e,g,h,i,j,k,l=[];f.isDomElement(a)&&(a=f.collectFormValues(a));for(d in b){g=f.getDeepObjectValue(a,d),h=f.result(b[d],g,a,d,c,b);for(e in h){if(i=f.validators[e],!i)throw k=f.format("Unknown validator %{name}",{name:e}),new Error(k);j=h[e],j=f.result(j,g,a,d,c,b),j&&l.push({attribute:d,error:i.call(i,g,j,d,a)})}}return l},processValidationResults:function(a,b){var c={};a.forEach(function(a){var b=a.error,d=a.attribute;f.isString(b)&&(b=[b]),b&&(c[d]=(c[d]||[]).concat(b))});for(var d in c)return f.fullMessages(c,b)},async:function(a,b,c){c=f.extend({},f.async.options,c);var d=f.runValidations(a,b,c);return f.Promise(function(b,e){f.waitForResults(d).then(function(){var g=f.processValidationResults(d,c);g?(c.flatten||(g=new f.ValidationErrors(g)),e(g)):b(a)}).then(void 0,f.error)})},waitForResults:function(a){var b=a.reduce(function(a,b){return f.isPromise(b.error)?a.then(function(){return b.error.then(function(){b.error=null},function(a){a||f.warn("Validator promise was rejected but didn't return an error"),b.error=a}).then(void 0,f.error)}).then(void 0,f.error):a},f.Promise(function(a){a()}));return b.then(void 0,f.error)},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return f.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&"function"==typeof a.then},isDomElement:function(a){return a&&f.isFunction(a.querySelectorAll)&&f.isFunction(a.querySelector)?f.isObject(document)&&a===document?!0:"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName:!1},isEmpty:function(a){var b;if(!f.isDefined(a))return!0;if(f.isFunction(a))return!1;if(f.isString(a))return f.EMPTY_STRING_REGEXP.test(a);if(f.isArray(a))return 0===a.length;if(f.isObject(a)){for(b in a)return!1;return!0}return!1},format:function(a,b){return a.replace(h,function(a,c){return String(b[c])})},prettify:function(a){return a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase()},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return f.isDefined(a)?f.isArray(a)?-1!==a.indexOf(b):b in a:!1},getDeepObjectValue:function(a,b){if(!f.isObject(a)||!f.isString(b))return void 0;var c,d="",e=!1;for(c=0;c<b.length;++c)switch(b[c]){case".":if(e)e=!1,d+=".";else{if(!(d in a))return void 0;a=a[d],d=""}break;case"\\":e?(e=!1,d+="\\"):e=!0;break;default:e=!1,d+=b[c]}return f.isDefined(a)&&d in a?a[d]:void 0},collectFormValues:function(a,b){var c,d,e,g,h={};if(!a)return h;for(b=b||{},e=a.querySelectorAll("input[name]"),c=0;c<e.length;++c)d=e.item(c),void 0===d.dataset.ignored&&(g=f.sanitizeFormValue(d.value,b),"number"===d.type?g=+g:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(e=a.querySelectorAll("select[name]"),c=0;c<e.length;++c)d=e.item(c),g=f.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&f.isString(a)&&(a=a.trim()),b.nullify!==!1&&""===a?null:a},capitalize:function(a){return f.isString(a)?a[0].toUpperCase()+a.slice(1):a},fullMessages:function(a,b){function c(a,c){c.forEach(function(c){"^"===c[0]?c=c.slice(1):b.fullMessages!==!1&&(c=f.format("%{attr} %{message}",{attr:f.capitalize(f.prettify(a)),message:c})),c=c.replace(/\\\^/g,"^"),b.flatten?e.push(c):(e[a]||(e[a]=[])).push(c)})}b=b||{};var d,e=b.flatten?[]:{};if(!a)return e;for(d in a)c(d,a[d]);return e},Promise:f.extend(function(a){var b=f.Promise.nativePromise(a)||f.Promise.RSVPPromise(a)||f.Promise.whenPromise(a)||f.Promise.QPromise(a);if(!b)throw new Error("No promises could be detected");return b},{nativePromise:function(a){var b,c;return"undefined"!=typeof Promise?b=Promise:(c=f.tryRequire("es6-promise"),c&&(b=c.Promise)),b?new b(a):void 0},RSVPPromise:function(a){var b,c;return"undefined"!=typeof RSVP?b=RSVP.Promise:(c=f.tryRequire("rsvp"),c&&(b=c.Promise)),b?new b(a):void 0},whenPromise:function(a){var b,c;return"undefined"!=typeof when?b=when.promise:(c=f.tryRequire("when"),c&&(b=c.promise)),b?b(a):void 0},QPromise:function(a){var b,c;return"undefined"!=typeof Q?b=Q.promise:(c=f.tryRequire("q"),c&&(b=c.promise)),b?b(a):void 0}}),tryRequire:function(a){if(!f.require)return null;try{return f.require(a)}catch(b){return null}},require:d,exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e("validate",[],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn(a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error(a)}}),e.validators={presence:function(a,b){return b=f.extend({},this.options,b),f.isEmpty(a)?b.message||this.message||"can't be blank":void 0},length:function(a,b,c){if(!f.isEmpty(a)){b=f.extend({},this.options,b);var d,e=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return f.isNumber(k)?(f.isNumber(e)&&k!==e&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(f.format(d,{count:e}))),f.isNumber(h)&&h>k&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(f.format(d,{count:h}))),f.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(f.format(d,{count:g}))),j.length>0?b.message||j:void 0):(f.error(f.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!f.isEmpty(a)){b=f.extend({},this.options,b);var c,d,e=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return b>a},lessThanOrEqualTo:function(a,b){return b>=a}};if(b.noStrings!==!0&&f.isString(a)&&(a=+a),!f.isNumber(a))return b.message||this.notValid||"is not a number";if(b.onlyInteger&&!f.isInteger(a))return b.message||this.notInteger||"must be an integer";for(c in g)if(d=b[c],f.isNumber(d)&&!g[c](a,d)){var h=this["not"+f.capitalize(c)]||"must be %{type} %{count}";e.push(f.format(h,{count:d,type:f.prettify(c)}))}return b.odd&&a%2!==1&&e.push(this.notOdd||"must be odd"),b.even&&a%2!==0&&e.push(this.notEven||"must be even"),e.length?b.message||e:void 0}},datetime:f.extend(function(a,b){if(!f.isEmpty(a)){b=f.extend({},this.options,b);var c,d=[],e=b.earliest?this.parse(b.earliest,b):0/0,g=b.latest?this.parse(b.latest,b):0/0;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?b.message||this.notValid||"must be a valid date":(!isNaN(e)&&e>a&&(c=this.tooEarly||"must be no earlier than %{date}",c=f.format(c,{date:this.format(e,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=this.tooLate||"must be no later than %{date}",c=f.format(c,{date:this.format(g,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:function(a){if(f.isFunction(g.XDate))return new g.XDate(a,!0).getTime();var b=f.tryRequire("moment")||g.moment;if(f.isDefined(b))return+b.utc(a);throw new Error("Neither XDate or moment.js was found")},format:function(a,b){var c=b.dateFormat;if(f.isFunction(g.XDate))return c=c||(b.dateOnly?"yyyy-MM-dd":"yyyy-MM-dd HH:mm:ss"),new XDate(a,!0).toString(c);var d=f.tryRequire("moment")||g.moment;if(f.isDefined(d))return c=c||(b.dateOnly?"YYYY-MM-DD":"YYYY-MM-DD HH:mm:ss"),d.utc(a).format(c);throw new Error("Neither XDate or moment.js was found")}}),date:function(a,b){return b=f.extend({},b,{dateOnly:!0}),f.validators.datetime.call(f.validators.datetime,a,b)},format:function(a,b){(f.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=f.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",e=b.pattern;return f.isEmpty(a)?void 0:f.isString(a)?(f.isString(e)&&(e=new RegExp(b.pattern,b.flags)),c=e.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!f.isEmpty(a)&&(f.isArray(b)&&(b={within:b}),b=f.extend({},this.options,b),!f.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return f.format(c,{value:a})}},exclusion:function(a,b){if(!f.isEmpty(a)&&(f.isArray(b)&&(b={within:b}),b=f.extend({},this.options,b),f.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return f.format(c,{value:a})}},email:f.extend(function(a,b){b=f.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!f.isEmpty(a))return f.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(a,b,c,d){if(!f.isEmpty(a)){f.isString(b)&&(b={attribute:b}),b=f.extend({},this.options,b);var e=b.message||this.message||"is not equal to %{attribute}";if(f.isEmpty(b.attribute)||!f.isString(b.attribute))throw new Error("The attribute must be a non empty string");var g=f.getDeepObjectValue(d,b.attribute),h=b.comparator||function(a,b){return a===b};return h(a,g,b,c,d)?void 0:f.format(e,{attribute:f.prettify(b.attribute)})}}},e.exposeModule(e,g,a,b,c)}).call(this,"undefined"!=typeof exports?exports:null,"undefined"!=typeof module?module:null,"undefined"!=typeof define?define:null,"undefined"!=typeof require?require:null); | ||
(function(a,b,c){"use strict";var d=function(a,b,c){c=e.extend({},e.options,c);var f,g,h=e.runValidations(a,b,c);for(f in h)for(g in h[f])if(e.isPromise(h[f][g]))throw new Error("Use validate.async if you want support for promises");return d.processValidationResults(h,c)},e=d;e.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},e.extend(d,{Promise:"undefined"!=typeof Promise?Promise:null,moment:"undefined"!=typeof moment?moment:null,XDate:"undefined"!=typeof XDate?XDate:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(a,b,c){var d,f,g,h,i,j,k,l=[];e.isDomElement(a)&&(a=e.collectFormValues(a));for(d in b){g=e.getDeepObjectValue(a,d),h=e.result(b[d],g,a,d,c,b);for(f in h){if(i=e.validators[f],!i)throw k=e.format("Unknown validator %{name}",{name:f}),new Error(k);j=h[f],j=e.result(j,g,a,d,c,b),j&&l.push({attribute:d,error:i.call(i,g,j,d,a)})}}return l},processValidationResults:function(a,b){var c={};a.forEach(function(a){var b=a.error,d=a.attribute;e.isString(b)&&(b=[b]),b&&(c[d]=(c[d]||[]).concat(b))});for(var d in c)return e.fullMessages(c,b)},async:function(a,b,c){c=e.extend({},e.async.options,c);var d=e.runValidations(a,b,c);return new e.Promise(function(b,f){e.waitForResults(d).then(function(){var g=e.processValidationResults(d,c);g?f(g):b(a)}).then(void 0,e.error)})},single:function(a,b,c){return c=e.extend({},e.single.options,c,{flatten:!0,fullMessages:!1}),e({single:a},{single:b},c)},waitForResults:function(a){var b=a.reduce(function(a,b){return e.isPromise(b.error)?a.then(function(){return b.error.then(function(){b.error=null},function(a){a||e.warn("Validator promise was rejected but didn't return an error"),b.error=a}).then(void 0,e.error)}).then(void 0,e.error):a},new e.Promise(function(a){a()}));return b.then(void 0,e.error)},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return e.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&e.isFunction(a.then)},isDomElement:function(a){return a&&e.isFunction(a.querySelectorAll)&&e.isFunction(a.querySelector)?e.isObject(document)&&a===document?!0:"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName:!1},isEmpty:function(a){var b;if(!e.isDefined(a))return!0;if(e.isFunction(a))return!1;if(e.isString(a))return e.EMPTY_STRING_REGEXP.test(a);if(e.isArray(a))return 0===a.length;if(e.isObject(a)){for(b in a)return!1;return!0}return!1},format:e.extend(function(a,b){return a.replace(e.format.FORMAT_REGEXP,function(a,c,d){return"%"===c?"%{"+d+"}":String(b[d])})},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(a){return a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase()},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return e.isDefined(a)?e.isArray(a)?-1!==a.indexOf(b):b in a:!1},getDeepObjectValue:function(a,b){if(!e.isObject(a)||!e.isString(b))return void 0;var c,d="",f=!1;for(c=0;c<b.length;++c)switch(b[c]){case".":if(f)f=!1,d+=".";else{if(!(d in a))return void 0;a=a[d],d=""}break;case"\\":f?(f=!1,d+="\\"):f=!0;break;default:f=!1,d+=b[c]}return e.isDefined(a)&&d in a?a[d]:void 0},collectFormValues:function(a,b){var c,d,f,g,h={};if(!a)return h;for(b=b||{},f=a.querySelectorAll("input[name]"),c=0;c<f.length;++c)d=f.item(c),void 0===d.dataset.ignored&&(g=e.sanitizeFormValue(d.value,b),"number"===d.type?g=+g:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(f=a.querySelectorAll("select[name]"),c=0;c<f.length;++c)d=f.item(c),g=e.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&e.isString(a)&&(a=a.trim()),b.nullify!==!1&&""===a?null:a},capitalize:function(a){return e.isString(a)?a[0].toUpperCase()+a.slice(1):a},fullMessages:function(a,b){function c(a,c){c.forEach(function(c){"^"===c[0]?c=c.slice(1):b.fullMessages!==!1&&(c=e.format("%{attr} %{message}",{attr:e.capitalize(e.prettify(a)),message:c})),c=c.replace(/\\\^/g,"^"),b.flatten?f.push(c):(f[a]||(f[a]=[])).push(c)})}b=b||{};var d,f=b.flatten?[]:{};if(!a)return f;for(d in a)c(d,a[d]);return f},exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e("validate",[],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn(a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error(a)}}),d.validators={presence:function(a,b){return b=e.extend({},this.options,b),e.isEmpty(a)?b.message||this.message||"can't be blank":void 0},length:function(a,b,c){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var d,f=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return e.isNumber(k)?(e.isNumber(f)&&k!==f&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(e.format(d,{count:f}))),e.isNumber(h)&&h>k&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(e.format(d,{count:h}))),e.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(e.format(d,{count:g}))),j.length>0?b.message||j:void 0):(e.error(e.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d,f=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return b>a},lessThanOrEqualTo:function(a,b){return b>=a}};if(b.noStrings!==!0&&e.isString(a)&&(a=+a),!e.isNumber(a))return b.message||this.notValid||"is not a number";if(b.onlyInteger&&!e.isInteger(a))return b.message||this.notInteger||"must be an integer";for(c in g)if(d=b[c],e.isNumber(d)&&!g[c](a,d)){var h=this["not"+e.capitalize(c)]||"must be %{type} %{count}";f.push(e.format(h,{count:d,type:e.prettify(c)}))}return b.odd&&a%2!==1&&f.push(this.notOdd||"must be odd"),b.even&&a%2!==0&&f.push(this.notEven||"must be even"),f.length?b.message||f:void 0}},datetime:e.extend(function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d=[],f=b.earliest?this.parse(b.earliest,b):0/0,g=b.latest?this.parse(b.latest,b):0/0;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?b.message||this.notValid||"must be a valid date":(!isNaN(f)&&f>a&&(c=this.tooEarly||"must be no earlier than %{date}",c=e.format(c,{date:this.format(f,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=this.tooLate||"must be no later than %{date}",c=e.format(c,{date:this.format(g,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:function(a){if(e.isFunction(e.XDate))return new e.XDate(a,!0).getTime();if(e.isDefined(e.moment))return+e.moment.utc(a);throw new Error("Neither XDate or moment.js was found")},format:function(a,b){var c=b.dateFormat;if(e.isFunction(e.XDate))return c=c||(b.dateOnly?"yyyy-MM-dd":"yyyy-MM-dd HH:mm:ss"),new XDate(a,!0).toString(c);if(e.isDefined(e.moment))return c=c||(b.dateOnly?"YYYY-MM-DD":"YYYY-MM-DD HH:mm:ss"),e.moment.utc(a).format(c);throw new Error("Neither XDate or moment.js was found")}}),date:function(a,b){return b=e.extend({},b,{dateOnly:!0}),e.validators.datetime.call(e.validators.datetime,a,b)},format:function(a,b){(e.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=e.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",f=b.pattern;return e.isEmpty(a)?void 0:e.isString(a)?(e.isString(f)&&(f=new RegExp(b.pattern,b.flags)),c=f.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),!e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return e.format(c,{value:a})}},exclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return e.format(c,{value:a})}},email:e.extend(function(a,b){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!e.isEmpty(a))return e.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(a,b,c,d){if(!e.isEmpty(a)){e.isString(b)&&(b={attribute:b}),b=e.extend({},this.options,b);var f=b.message||this.message||"is not equal to %{attribute}";if(e.isEmpty(b.attribute)||!e.isString(b.attribute))throw new Error("The attribute must be a non empty string");var g=e.getDeepObjectValue(d,b.attribute),h=b.comparator||function(a,b){return a===b};return h(a,g,b,c,d)?void 0:e.format(f,{attribute:e.prettify(b.attribute)})}}},d.exposeModule(d,this,a,b,c)}).call(this,"undefined"!=typeof exports?exports:null,"undefined"!=typeof module?module:null,"undefined"!=typeof define?define:null); | ||
//# sourceMappingURL=validate.min.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
1
44
1
821246
46
7525