Socket
Socket
Sign inDemoInstall

@lion/validate

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lion/validate - npm Package Compare versions

Comparing version 0.6.5 to 0.6.6

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [0.6.6](https://github.com/ing-bank/lion/compare/@lion/validate@0.6.5...@lion/validate@0.6.6) (2020-02-06)
### Bug Fixes
* **validator:** throw error if getMessage not of type Function ([ce3c02b](https://github.com/ing-bank/lion/commit/ce3c02b63bf8bc807946457c1a9289b8b57b5ee2))
## [0.6.5](https://github.com/ing-bank/lion/compare/@lion/validate@0.6.4...@lion/validate@0.6.5) (2020-02-03)

@@ -8,0 +19,0 @@

8

package.json
{
"name": "@lion/validate",
"version": "0.6.5",
"version": "0.6.6",
"description": "Validate your form elements",

@@ -37,4 +37,4 @@ "author": "ing-bank",

"dependencies": {
"@lion/core": "0.4.2",
"@lion/localize": "0.8.5"
"@lion/core": "0.4.3",
"@lion/localize": "0.8.6"
},

@@ -46,3 +46,3 @@ "devDependencies": {

},
"gitHead": "30a8197f18bf1f27fc41f392bde517a5fb94cbcd"
"gitHead": "d67225984ce359c421e1c1e350da98819f83e452"
}

@@ -61,4 +61,10 @@ import { fakeExtendsEventTarget } from './utils/fake-extends-event-target.js';

};
if (typeof this.config.getMessage === 'function') {
return this.config.getMessage(composedData);
if (this.config.getMessage) {
if (typeof this.config.getMessage === 'function') {
return this.config.getMessage(composedData);
}
throw new Error(
`You must provide a value for getMessage of type 'function', you provided a value of type: ${typeof this
.config.getMessage}`,
);
}

@@ -65,0 +71,0 @@ return this.constructor.getMessage(composedData);

import { expect, fixture, html, unsafeStatic, defineCE } from '@open-wc/testing';
import sinon from 'sinon';
import { LitElement } from '@lion/core';
import sinon from 'sinon';
import { ValidateMixin } from '../src/ValidateMixin.js';
import { Validator } from '../src/Validator.js';
async function expectThrowsAsync(method, errorMessage) {
let error = null;
try {
await method();
} catch (err) {
error = err;
}
expect(error).to.be.an('Error', 'No error was thrown');
if (errorMessage) {
expect(error.message).to.equal(errorMessage);
}
}
describe('Validator', () => {

@@ -25,2 +38,16 @@ it('has an "execute" function returning "shown" state', async () => {

it('throws when executing a Validator that has a getMessage config property with a value not of type function', async () => {
class MyValidator extends Validator {
constructor(...args) {
super(...args);
this.name = 'MyValidator';
}
}
await expectThrowsAsync(
() => new MyValidator({}, { getMessage: 'This is the custom error message' })._getMessage(),
"You must provide a value for getMessage of type 'function', you provided a value of type: string",
);
});
it('receives a "param" as a first argument on instantiation', async () => {

@@ -27,0 +54,0 @@ const vali = new Validator('myParam');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc