mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: add weight validation in UI
This commit is contained in:
parent
f61e1ebba8
commit
8255f57abb
@ -121,7 +121,9 @@
|
||||
"file_error": "File not found",
|
||||
"audio_error": "Audio not found",
|
||||
"video_error": "Video not found",
|
||||
"missing_fields_error": "Please make sure that all required fields are filled"
|
||||
"missing_fields_error": "Please make sure that all required fields are filled",
|
||||
"weight_required_error": "Weight is required or invalid.",
|
||||
"weight_positive_integer_error": "Weight must be a positive integer"
|
||||
},
|
||||
"menu": {
|
||||
"terms": "Terms of Use",
|
||||
|
@ -121,7 +121,9 @@
|
||||
"file_error": "Fichier introuvable",
|
||||
"audio_error": "Audio introuvable",
|
||||
"video_error": "Vidéo introuvable",
|
||||
"missing_fields_error": "Veuillez vous assurer que tous les champs sont remplis correctement"
|
||||
"missing_fields_error": "Veuillez vous assurer que tous les champs sont remplis correctement",
|
||||
"weight_positive_integer_error": "Le poids doit être un nombre entier positif",
|
||||
"weight_required_error": "Le poids est requis ou bien invalide"
|
||||
},
|
||||
"menu": {
|
||||
"terms": "Conditions d'utilisation",
|
||||
|
@ -135,11 +135,29 @@ export const NlpEntityVarForm: FC<ComponentFormProps<INlpEntity>> = ({
|
||||
/>
|
||||
</ContentItem>
|
||||
<ContentItem>
|
||||
<Input
|
||||
label={t("label.weight")}
|
||||
{...register("weight", { valueAsNumber: true })}
|
||||
type="number"
|
||||
inputProps={{ min: 1, step: 1 }} // Restricts input to positive integers only
|
||||
<Input
|
||||
label={t("label.weight")}
|
||||
{...register("weight", {
|
||||
valueAsNumber: true,
|
||||
required: t("message.weight_required_error"),
|
||||
min: {
|
||||
value: 1,
|
||||
message: t("message.weight_positive_integer_error"),
|
||||
},
|
||||
validate: (value) =>
|
||||
Number.isInteger(value) && value > 0
|
||||
? true
|
||||
: t("message.weight_positive_integer_error"),
|
||||
})}
|
||||
type="number"
|
||||
inputProps={{
|
||||
min: 1,
|
||||
step: 1,
|
||||
inputMode: "numeric",
|
||||
pattern: "[1-9][0-9]*",
|
||||
}}
|
||||
error={!!errors.weight}
|
||||
helperText={errors.weight?.message}
|
||||
/>
|
||||
</ContentItem>
|
||||
</ContentContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user