Skip to content

Commit

Permalink
UIQM-526 Fix some code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis committed Dec 13, 2023
1 parent 2cd2faa commit cb4fc25
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [UIQM-522](https://issues.folio.org/browse/UIQM-522) Create/Derive a new MARC bib record & Create a MARC holdings | Default state of Save & close button should be disabled.
* [UIQM-534](https://issues.folio.org/browse/UIQM-534) Remove fields that have no MARC tag and no subfield value.
* [UIQM-381](https://issues.folio.org/browse/UIQM-381) Create Orig Authority Record: Populate new record with default Leader values.
* [UIQM-526](https://issues.folio.org/browse/UIQM-526) Refactor validation functionality.

## [7.0.5](https://github.com/folio-org/ui-quick-marc/tree/v7.0.5) (2023-12-11)

Expand Down
1 change: 0 additions & 1 deletion src/QuickMarcEditor/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
CREATE_AUTHORITY_RECORD_DEFAULT_FIELD_TAGS,
UNCONTROLLED_ALPHA,
UNCONTROLLED_NUMBER,
TAG_LENGTH,
AUTHORITY_FIXED_FIELD_DEFAULT_TYPE,
} from './constants';
import { RECORD_STATUS_NEW } from './QuickMarcRecordInfo/constants';
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/useValidation/useValidation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useCallback } from 'react';
import { validators } from './rules';

const useValidation = (context) => {
const validate = useCallback((marcRecords) => {
const validate = (marcRecords) => {
const validationRules = validators[context.marcType][context.action];

const errorMessage = validationRules.reduce((_errorMessage, rule) => {
Expand All @@ -20,7 +19,7 @@ const useValidation = (context) => {
}, null);

return errorMessage;
}, [context]);
};

return { validate };
};
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/useValidation/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const validateEmptySubfields = ({ marcRecords }, rule) => {
export const validateSubfieldValueExists = (context, rule) => {
const { marcRecords } = context;

if (rule.ignore && rule.ignore(context)) {
if (rule.ignore?.()) {
return undefined;
}

Expand All @@ -73,7 +73,7 @@ export const validateSubfieldValueExists = (context, rule) => {
export const validateExistence = (context, rule) => {
const { marcRecords } = context;

if (rule.ignore && rule.ignore(context)) {
if (rule.ignore?.()) {
return undefined;
}

Expand Down Expand Up @@ -186,7 +186,7 @@ export const validate$9InLinkable = ({ marcRecords, linkableBibFields }, rule) =
export const validateTagChanged = (context, rule) => {
const { marcRecords, initialValues } = context;

if (rule.ignore && rule.ignore(context)) {
if (rule.ignore?.()) {
return undefined;
}

Expand All @@ -201,7 +201,7 @@ export const validateTagChanged = (context, rule) => {
return undefined;
};
export const validateSubfieldChanged = (context, rule) => {
if (rule.ignore && rule.ignore(context)) {
if (rule.ignore?.()) {
return undefined;
}

Expand Down

0 comments on commit cb4fc25

Please sign in to comment.