mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
add live validation for page handler (#10491)
This commit is contained in:
parent
5bb033f7e3
commit
915b91297c
1 changed files with 5 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import React, { useState } from 'react';
|
||||
import { ToolTip } from '@/Editor/Inspector/Elements/Components/ToolTip';
|
||||
import { validateKebabCase } from '@/_helpers/utils';
|
||||
|
||||
export const EditInput = ({ slug, error, setError, pageHandle, setPageHandle, isSaving = false }) => {
|
||||
const [value, set] = useState(pageHandle);
|
||||
|
|
@ -10,7 +11,10 @@ export const EditInput = ({ slug, error, setError, pageHandle, setPageHandle, is
|
|||
|
||||
if (newHandle === '') setError('Page handle cannot be empty');
|
||||
if (newHandle === value) setError('Page handle cannot be same as the existing page handle');
|
||||
|
||||
const isValidKebabCase = validateKebabCase(newHandle);
|
||||
if (!isValidKebabCase.isValid) {
|
||||
setError(isValidKebabCase.error);
|
||||
}
|
||||
set(newHandle);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue