File tree Expand file tree Collapse file tree 1 file changed +7
-19
lines changed
Expand file tree Collapse file tree 1 file changed +7
-19
lines changed Original file line number Diff line number Diff line change 851851 let isValid = true ;
852852 const dirtyValues = getDirtyValues (grps);
853853
854- for (let attributeId in state .requiredAttributes ) {
855- const attribute = state .requiredAttributes [attributeId];
856-
854+ for (let attribute of state .requiredAttributes ) {
855+ const dataExists = Boolean (state .entity .data [attribute .id ]? .id );
856+ const isKeyInDirtyValue = hasKey (dirtyValues, attribute .id );
857+ const isDirtyValueEmpty = isEmpty (dirtyValues[attribute .id ]);
857858 // check if existing value has an empty dirty value
858859 // -> delete operation
859- if (
860- state .entity .data [attribute .id ]? .id
861- &&
862- hasKey (dirtyValues, attribute .id )
863- &&
864- isEmpty (dirtyValues[attribute .id ])
865- ) {
860+ if (dataExists && isKeyInDirtyValue && isDirtyValueEmpty) {
866861 isValid = false ;
867862 break ;
868863 }
869864 // check if there is neither an existing valur nor:
870865 // a) an existing entry in dirty values
871866 // b) or the dirty value is empty
872867 // -> missing
873- if (
874- ! state .entity .data [attribute .id ]? .id
875- &&
876- (
877- ! hasKey (dirtyValues, attribute .id )
878- ||
879- isEmpty (dirtyValues[attribute .id ])
880- )
881- ) {
868+ const noDirtyData = ! isKeyInDirtyValue || isDirtyValueEmpty;
869+ if (! dataExists && noDirtyData) {
882870 isValid = false ;
883871 break ;
884872 }
You can’t perform that action at this time.
0 commit comments