Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-2536 (pull request #641)
Browse files Browse the repository at this point in the history
Fixed max length validation for shib configurations

Approved-by: Doug Sonaty
  • Loading branch information
rmathis committed Feb 16, 2023
2 parents 0417d0c + feaebfa commit 3c21843
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ui/src/app/admin/component/ConfigurationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function ConfigurationForm({ configurations, configuration = {}, loading,

const [names, setNames] = React.useState([]);

const { control, register, getValues, watch, formState: { errors, isValid }, handleSubmit } = useForm({
const { control, register, getValues, watch, formState, handleSubmit } = useForm({
defaultValues: {
...configuration
},
Expand All @@ -34,6 +34,8 @@ export function ConfigurationForm({ configurations, configuration = {}, loading,
}
});

const { errors, isValid } = formState;

const properties = useProperties();

const addProperties = (props) => {
Expand Down Expand Up @@ -113,8 +115,10 @@ export function ConfigurationForm({ configurations, configuration = {}, loading,
placeholder={translator('label.configuration-name-placeholder')}
{...register(`name`, {
required: true,
maxLength: 255,
value: configuration.value || null,
validate: {

unique: v => v.trim() === configuration.name || !includes(names, v)
}
})} />
Expand Down Expand Up @@ -160,8 +164,10 @@ export function ConfigurationForm({ configurations, configuration = {}, loading,
<Form.Control
type={p.displayType === 'number' ? 'number' : 'text'}
placeholder="value"
isInvalid={ errors?.properties && errors.properties[idx] }
{...register(`properties.${idx}.propertyValue`, {
setValueAs: v => (p.displayType === 'number' ? parseInt(v) : v),
maxLength: 255,
})} />
</FloatingLabel>
:
Expand Down

0 comments on commit 3c21843

Please sign in to comment.