@@ -4,12 +4,12 @@ import { Actions } from '../models/actions';
44import { Rule , UniqueConstraint , CallbackConstraint } from '../models/rule' ;
55import { ValidationError } from '../models/validation' ;
66
7- const onlyUniqueValues = ( data : string [ ] ) => {
8- return new Set ( data ) . size === data . length ;
7+ const onlyUniqueValues = ( values : string [ ] ) => {
8+ return new Set ( values ) . size === values . length ;
99} ;
1010
11- const findDuplicates = ( data : string [ ] ) => {
12- return Array . from ( new Set ( data . filter ( ( item , index ) => data . indexOf ( item ) != index ) ) ) ;
11+ const getDuplicates = ( values : string [ ] ) => {
12+ return Array . from ( new Set ( values . filter ( ( item , index ) => values . indexOf ( item ) != index ) ) ) ;
1313} ;
1414
1515const validateColumn = < T > ( key : keyof T , data : T [ keyof T ] [ ] , rules ?: Rule [ ] ) : ValidationError < T > [ ] => {
@@ -19,7 +19,7 @@ const validateColumn = <T>(key: keyof T, data: T[keyof T][], rules?: Rule[]): Va
1919 const values = data . map ( ( d ) => new String ( d ) . toString ( ) ) ;
2020 rules . forEach ( ( r ) => {
2121 if ( ( r . constraint as UniqueConstraint ) . unique && ! onlyUniqueValues ( values ) ) {
22- const duplicates = findDuplicates ( values ) ;
22+ const duplicates = getDuplicates ( values ) ;
2323 values . forEach ( ( v , i ) => {
2424 if ( duplicates . indexOf ( v ) !== - 1 ) {
2525 errors . push ( { column : key , row : i , message : r . message } ) ;
0 commit comments