rename guards to utils
Signed-off-by: Paul Cowan <paul.cowan@cutting.scot>
This commit is contained in:
@@ -38,7 +38,7 @@ import { useFormDataFromQuery } from '../../hooks';
|
||||
import { FormProps } from '../../types';
|
||||
import { LayoutOptions } from '../../../layouts';
|
||||
import { useTransformSchemaToProps } from '../../hooks/useTransformSchemaToProps';
|
||||
import { hasErrors } from './guards';
|
||||
import { hasErrors } from './utils';
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
backButton: {
|
||||
|
||||
@@ -28,10 +28,9 @@ function isObject(value: JsonValue | undefined): value is JsonObject {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type FormValidation = Record<
|
||||
string,
|
||||
FieldValidation | Record<string, FieldValidation>
|
||||
>;
|
||||
export type FormValidation = {
|
||||
[name: string]: FieldValidation | FormValidation;
|
||||
};
|
||||
|
||||
export const createAsyncValidators = (
|
||||
rootSchema: JsonObject,
|
||||
@@ -64,10 +63,7 @@ export const createAsyncValidators = (
|
||||
formValidation[key] = fieldValidation;
|
||||
}
|
||||
} else if (isObject(value)) {
|
||||
formValidation[key] = (await validate(formData, path, value)) as Record<
|
||||
string,
|
||||
FieldValidation
|
||||
>;
|
||||
formValidation[key] = await validate(formData, path, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user