- added table validation custom function;
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import validate from 'validate.js';
|
||||
import { match, isEmpty, is } from 'ramda';
|
||||
import { match, isEmpty, is, pathOr, isNil } from 'ramda';
|
||||
import CodiceFiscale from 'codice-fiscale-js';
|
||||
|
||||
export const isPIVA = (v) => {
|
||||
@@ -67,12 +67,31 @@ export const maxChecks = (v, num) => {
|
||||
return is(Array, v) ? v.length <= parseInt(num) : false;
|
||||
}
|
||||
|
||||
export const nonEmptyTables = (v = [], colsCfg = []) => {
|
||||
export const nonEmptyTables = (v = [], tableCfg = []) => {
|
||||
//console.log('nonEmptyTables',v)
|
||||
/*const cellValues = v.map(row => {
|
||||
const colsCfg = pathOr([], ['stateFieldData'], tableCfg);
|
||||
const nonPredefinedCells = colsCfg
|
||||
.filter(o => !o.predefined)
|
||||
.map(o => o.name);
|
||||
let isTableValid = true;
|
||||
let atLeastOneCellFilled = false
|
||||
|
||||
return isEmpty(row)
|
||||
// eslint-disable-next-line array-callback-return
|
||||
v.map((row) => {
|
||||
if (isEmpty(row)) {
|
||||
isTableValid = false;
|
||||
} else {
|
||||
// eslint-disable-next-line array-callback-return
|
||||
nonPredefinedCells.map((k) => {
|
||||
if (isNil(row[k]) || isEmpty(row[k])) {
|
||||
isTableValid = atLeastOneCellFilled;
|
||||
} else {
|
||||
atLeastOneCellFilled = true;
|
||||
isTableValid = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
console.log('cellValues', cellValues, colsCfg)*/
|
||||
return is(Array, v) ? v.length >= 1 : false;
|
||||
|
||||
return is(Array, v) ? v.length >= 1 && isTableValid : false;
|
||||
}
|
||||
Reference in New Issue
Block a user