db-vendo-client/test/e2e/lib/validate-fptf-with.js
Kristjan ESPERANTO 66d9fb5194
apply linting rules
follow-up of 228c7253
2024-02-10 16:50:12 +01:00

27 lines
714 B
JavaScript

import validateFptf from 'validate-fptf';
const {defaultValidators} = validateFptf;
import anyOf from 'validate-fptf/lib/any-of.js';
import validators from './validators.js';
const createValidateFptfWith = (cfg, customValidators = {}) => {
const val = Object.assign({}, defaultValidators);
for (let key of Object.keys(validators)) {
val[key] = validators[key](cfg);
}
Object.assign(val, customValidators);
const validateFptfWith = (t, item, allowedTypes, name) => {
if ('string' === typeof allowedTypes) {
val[allowedTypes](val, item, name);
} else {
anyOf(allowedTypes, val, item, name);
}
t.pass(name + ' is valid');
};
return validateFptfWith;
};
export {
createValidateFptfWith,
};