test(validators): validatorName instead of name
This commit is contained in:
parent
3ef736bacf
commit
83f0b112aa
7 changed files with 22 additions and 24 deletions
|
|
@ -423,7 +423,7 @@ export const ValidateMixin = dedupeMixin(
|
|||
if (!validationStates[v.type]) {
|
||||
validationStates[v.type] = {};
|
||||
}
|
||||
validationStates[v.type][v.constructor.name] = true;
|
||||
validationStates[v.type][v.constructor.validatorName] = true;
|
||||
});
|
||||
this.validationStates = validationStates;
|
||||
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ export function runValidateMixinSuite(customConfig) {
|
|||
}
|
||||
|
||||
static get validatorName() {
|
||||
return 'isCat';
|
||||
return 'IsCat';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ export function runValidateMixinFeedbackPart() {
|
|||
}
|
||||
|
||||
render() {
|
||||
return html`Custom for ${this.feedbackData[0].validator.constructor.name}`;
|
||||
return html`Custom for ${this.feedbackData[0].validator.constructor.validatorName}`;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -348,9 +348,8 @@ describe('<lion-field>', () => {
|
|||
});
|
||||
it('should not run validation when disabled', async () => {
|
||||
const HasX = class extends Validator {
|
||||
constructor() {
|
||||
super();
|
||||
this.name = 'HasX';
|
||||
static get validatorName() {
|
||||
return 'HasX';
|
||||
}
|
||||
|
||||
execute(value) {
|
||||
|
|
@ -385,9 +384,8 @@ describe('<lion-field>', () => {
|
|||
|
||||
it('should remove validation when disabled state toggles', async () => {
|
||||
const HasX = class extends Validator {
|
||||
constructor() {
|
||||
super();
|
||||
this.name = 'HasX';
|
||||
static get validatorName() {
|
||||
return 'HasX';
|
||||
}
|
||||
|
||||
execute(value) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ describe('Date Validation', () => {
|
|||
it('provides new isDate() to allow only dates', () => {
|
||||
let isEnabled;
|
||||
const validator = new IsDate();
|
||||
expect(validator.constructor.name).to.equal('IsDate');
|
||||
expect(validator.constructor.validatorName).to.equal('IsDate');
|
||||
|
||||
isEnabled = validator.execute(new Date());
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -28,7 +28,7 @@ describe('Date Validation', () => {
|
|||
it('provides new minDate(x) to allow only dates after min', () => {
|
||||
let isEnabled;
|
||||
const validator = new MinDate(new Date('2018/02/02'));
|
||||
expect(validator.constructor.name).to.equal('MinDate');
|
||||
expect(validator.constructor.validatorName).to.equal('MinDate');
|
||||
|
||||
isEnabled = validator.execute(new Date('2018-02-03'));
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -46,7 +46,7 @@ describe('Date Validation', () => {
|
|||
it('provides maxDate() to allow only dates before max', () => {
|
||||
let isEnabled;
|
||||
const validator = new MaxDate(new Date('2018/02/02'));
|
||||
expect(validator.constructor.name).to.equal('MaxDate');
|
||||
expect(validator.constructor.validatorName).to.equal('MaxDate');
|
||||
|
||||
isEnabled = validator.execute(new Date('2018-02-01'));
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -67,7 +67,7 @@ describe('Date Validation', () => {
|
|||
min: new Date('2018/02/02'),
|
||||
max: new Date('2018/02/04'),
|
||||
});
|
||||
expect(validator.constructor.name).to.equal('MinMaxDate');
|
||||
expect(validator.constructor.validatorName).to.equal('MinMaxDate');
|
||||
|
||||
isEnabled = validator.execute(new Date('2018/02/03'));
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -88,7 +88,7 @@ describe('Date Validation', () => {
|
|||
it('provides new IsDateDisabled() to disable dates matching specified condition', () => {
|
||||
let isDisabled;
|
||||
const validator = new IsDateDisabled(d => d.getDate() === 3);
|
||||
expect(validator.constructor.name).to.equal('IsDateDisabled');
|
||||
expect(validator.constructor.validatorName).to.equal('IsDateDisabled');
|
||||
|
||||
isDisabled = validator.execute(new Date('2018/02/04'));
|
||||
expect(isDisabled).to.be.false;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe('Number Validation', () => {
|
|||
it('provides new IsNumber() to allow only numbers', () => {
|
||||
let isEnabled;
|
||||
const validator = new IsNumber();
|
||||
expect(validator.constructor.name).to.equal('IsNumber');
|
||||
expect(validator.constructor.validatorName).to.equal('IsNumber');
|
||||
|
||||
isEnabled = validator.execute(4);
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -26,7 +26,7 @@ describe('Number Validation', () => {
|
|||
it('provides new MinNumber(x) to allow only numbers longer then min', () => {
|
||||
let isEnabled;
|
||||
const validator = new MinNumber(3);
|
||||
expect(validator.constructor.name).to.equal('MinNumber');
|
||||
expect(validator.constructor.validatorName).to.equal('MinNumber');
|
||||
|
||||
isEnabled = validator.execute(3);
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -38,7 +38,7 @@ describe('Number Validation', () => {
|
|||
it('provides new MaxNumber(x) to allow only number shorter then max', () => {
|
||||
let isEnabled;
|
||||
const validator = new MaxNumber(3);
|
||||
expect(validator.constructor.name).to.equal('MaxNumber');
|
||||
expect(validator.constructor.validatorName).to.equal('MaxNumber');
|
||||
|
||||
isEnabled = validator.execute(3);
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -50,7 +50,7 @@ describe('Number Validation', () => {
|
|||
it('provides new MinMaxNumber({ min: x, max: y}) to allow only numbers between min and max', () => {
|
||||
let isEnabled;
|
||||
const validator = new MinMaxNumber({ min: 2, max: 4 });
|
||||
expect(validator.constructor.name).to.equal('MinMaxNumber');
|
||||
expect(validator.constructor.validatorName).to.equal('MinMaxNumber');
|
||||
|
||||
isEnabled = validator.execute(2);
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ describe('String Validation', () => {
|
|||
it('provides new IsString() to allow only strings', () => {
|
||||
let isEnabled;
|
||||
const validator = new IsString();
|
||||
expect(validator.constructor.name).to.equal('IsString');
|
||||
expect(validator.constructor.validatorName).to.equal('IsString');
|
||||
|
||||
isEnabled = validator.execute('foo');
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -29,7 +29,7 @@ describe('String Validation', () => {
|
|||
it('provides new EqualsLength(x) to allow only a specific string length', () => {
|
||||
let isEnabled;
|
||||
const validator = new EqualsLength(3);
|
||||
expect(validator.constructor.name).to.equal('EqualsLength');
|
||||
expect(validator.constructor.validatorName).to.equal('EqualsLength');
|
||||
|
||||
isEnabled = validator.execute('foo');
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -44,7 +44,7 @@ describe('String Validation', () => {
|
|||
it('provides new MinLength(x) to allow only strings longer then min', () => {
|
||||
let isEnabled;
|
||||
const validator = new MinLength(3);
|
||||
expect(validator.constructor.name).to.equal('MinLength');
|
||||
expect(validator.constructor.validatorName).to.equal('MinLength');
|
||||
|
||||
isEnabled = validator.execute('foo');
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -56,7 +56,7 @@ describe('String Validation', () => {
|
|||
it('provides new MaxLength(x) to allow only strings shorter then max', () => {
|
||||
let isEnabled;
|
||||
const validator = new MaxLength(3);
|
||||
expect(validator.constructor.name).to.equal('MaxLength');
|
||||
expect(validator.constructor.validatorName).to.equal('MaxLength');
|
||||
|
||||
isEnabled = validator.execute('foo');
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -68,7 +68,7 @@ describe('String Validation', () => {
|
|||
it('provides new MinMaxValidator({ min: x, max: y}) to allow only strings between min and max', () => {
|
||||
let isEnabled;
|
||||
const validator = new MinMaxLength({ min: 2, max: 4 });
|
||||
expect(validator.constructor.name).to.equal('MinMaxLength');
|
||||
expect(validator.constructor.validatorName).to.equal('MinMaxLength');
|
||||
|
||||
isEnabled = validator.execute('foo');
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
@ -83,7 +83,7 @@ describe('String Validation', () => {
|
|||
it('provides new IsEmail() to allow only valid email formats', () => {
|
||||
let isEnabled;
|
||||
const validator = new IsEmail();
|
||||
expect(validator.constructor.name).to.equal('IsEmail');
|
||||
expect(validator.constructor.validatorName).to.equal('IsEmail');
|
||||
|
||||
isEnabled = validator.execute('foo@bar.com');
|
||||
expect(isEnabled).to.be.false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue