So I'm converting an old Knockout blade to react, and I need to add multiple validations to a FluentUI TextField component. The example picture is what these validations should look like, but as of now, I have not been able to find an example of someone doing something similar with this component. I attached what I am currently using for the name field as that only requires one validation, but any help would be greatly appreciated. I am still relatively new to React/TypeScript so please bear that in mind.
const nameValidation = new RegExp("^$|^[A-Za-z][-A-Za-z0-9]{4,48}[A-Za-z0-9]$");
const validateAndGetError = (value:string): string => {
return nameValidation.test(value) ? "" : ClientResources.Error.Message.validationEntityNameInvalid;
}
// the textfield is receiving the validate through onGetErrorMessage
<TextField styles={fieldStyles} placeholder={props.nameFieldPlaceholder} onGetErrorMessage={validateAndGetError} validateOnFocusOut onChange={(_, n) => setName(n)} />