add basic validation

This commit is contained in:
mfrances 2021-06-09 08:59:01 -04:00
parent 4bf8930cd4
commit 7ba357c223
2 changed files with 10 additions and 3 deletions

View file

@ -10,6 +10,7 @@ import {
SelectOption, SelectOption,
SelectVariant, SelectVariant,
TextInput, TextInput,
ValidatedOptions
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import { convertFormValuesToObject, convertToFormValues } from "../../../util"; import { convertFormValuesToObject, convertToFormValues } from "../../../util";
import type ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation"; import type ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation";
@ -158,7 +159,10 @@ export const LdapMapperDetails = () => {
id="kc-ldap-mapper-name" id="kc-ldap-mapper-name"
data-testid="ldap-mapper-name" data-testid="ldap-mapper-name"
name="name" name="name"
ref={form.register} ref={form.register({ required: true})}
validated={
form.errors.name ? ValidatedOptions.error : ValidatedOptions.default
}
/> />
<TextInput <TextInput
hidden hidden

View file

@ -1,4 +1,4 @@
import { FormGroup, TextInput } from "@patternfly/react-core"; import { FormGroup, TextInput, ValidatedOptions } from "@patternfly/react-core";
import React from "react"; import React from "react";
import { HelpItem } from "../../../components/help-enabler/HelpItem"; import { HelpItem } from "../../../components/help-enabler/HelpItem";
import type { UseFormMethods } from "react-hook-form"; import type { UseFormMethods } from "react-hook-form";
@ -34,7 +34,10 @@ export const LdapMapperHardcodedLdapGroup = ({
id="kc-group" id="kc-group"
data-testid="mapper-group-fld" data-testid="mapper-group-fld"
name="config.group[0]" name="config.group[0]"
ref={form.register} ref={form.register({ required: true })}
validated={
form.errors.config && form.errors.config.group ? ValidatedOptions.error : ValidatedOptions.default
}
/> />
</FormGroup> </FormGroup>
</> </>