rename isInvalid to hasErrors

Signed-off-by: Paul Cowan <paul.cowan@cutting.scot>
This commit is contained in:
Paul Cowan
2023-02-06 14:42:25 +00:00
parent 5555e17313
commit ba437049cc
2 changed files with 4 additions and 4 deletions
@@ -35,7 +35,7 @@ import { useFormDataFromQuery } from '../../hooks';
import { FormProps } from '../../types';
import { LayoutOptions } from '../../../layouts';
import { useTransformSchemaToProps } from '../../hooks/useTransformSchemaToProps';
import { isInvalid } from './guards';
import { hasErrors } from './guards';
const useStyles = makeStyles(theme => ({
backButton: {
@@ -137,7 +137,7 @@ export const Stepper = (stepperProps: StepperProps) => {
const returnedValidation = await validation(formData);
if (isInvalid(returnedValidation)) {
if (hasErrors(returnedValidation)) {
setErrors(returnedValidation);
} else {
setErrors(undefined);
@@ -19,7 +19,7 @@ function isFieldValidation(error: any): error is FieldValidation {
return !!error && '__errors' in error;
}
export function isInvalid(errors?: Record<string, FieldValidation>): boolean {
export function hasErrors(errors?: Record<string, FieldValidation>): boolean {
if (!errors) {
return false;
}
@@ -29,7 +29,7 @@ export function isInvalid(errors?: Record<string, FieldValidation>): boolean {
return (error.__errors ?? []).length > 0;
}
return isInvalid(error);
return hasErrors(error);
}
return false;