rename isInvalid to hasErrors
Signed-off-by: Paul Cowan <paul.cowan@cutting.scot>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user