Skip to content

Commit

Permalink
feat(Scheduling): changed validation for name [YTFRONT-4319]
Browse files Browse the repository at this point in the history
  • Loading branch information
SimbiozizV committed Aug 23, 2024
1 parent 7d66e6c commit 7bd7852
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ interface FormValues {
responsible: {value: string; id: string | number; title: string};
}

const NAME_REGEXP = /^[A-Za-z0-9-_]+$/;

function CreatePoolDialog(props: {onClose: () => void}) {
const dispatch = useDispatch();
const treeStored: string = useSelector(getTree);
Expand Down Expand Up @@ -122,12 +120,9 @@ function CreatePoolDialog(props: {onClose: () => void}) {

const validateForm = React.useCallback(
(values: FormValues): null | {name?: string} => {
//const {values} = form.getState();
const {name} = values;
const res: Partial<Record<keyof FormValues, string>> = {};
if (!NAME_REGEXP.test(name)) {
res.name = `the value must match regexp: ${NAME_REGEXP}`;
} else if (-1 !== _.sortedIndexOf(sortedFlatTree, name)) {
if (-1 !== _.sortedIndexOf(sortedFlatTree, name)) {
res.name = 'the value must be unique';
}
return _.isEmpty(res) ? null : res;
Expand Down

0 comments on commit 7bd7852

Please # to comment.