Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-8074 fixed error message for argument section #422

Closed
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function ArgumentSection(props: ArgumentsProps) {
value = formik.values.other;
}
const fnToAdd = {
argumentName: formik.values.argumentName,
argumentName: formik.values.argumentName?.trim(),
dataType: value,
};
addArgumentToFunctionsArguments(fnToAdd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function FunctionBuilder({
const getFunctionArguments = (args) => {
let argStr = "";
args?.forEach((arg) => {
argStr += arg.argumentName + " " + arg.dataType + ", ";
argStr += `"${arg.argumentName}"` + " " + arg.dataType + ", ";
});
argStr = argStr.substring(0, argStr.length - 2);
return argStr;
Expand Down Expand Up @@ -272,8 +272,8 @@ export default function FunctionBuilder({
operation === "edit"
? () => {
const functionToEdit = {
functionName: funct.name,
comment: funct.comment,
functionName: funct.name?.trim(),
comment: funct.comment?.trim(),
functionsArguments: funct.functionsArguments,
fluentFunction: funct.fluentFunction,
expressionValue: funct.expressionEditorValue,
Expand All @@ -285,8 +285,8 @@ export default function FunctionBuilder({
}
: () => {
const functionToApply = {
functionName: formik.values.functionName,
comment: formik.values.comment,
functionName: formik.values.functionName?.trim(),
comment: formik.values.comment?.trim(),
functionsArguments: formik.values.functionsArguments,
fluentFunction: formik.values.fluentFunction,
expressionValue: formik.values.expressionEditorValue,
Expand Down
2 changes: 1 addition & 1 deletion src/validations/FunctionArgumentSchemaValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Yup from "yup";

export const FunctionArgumentSchemaValidator = Yup.object().shape({
argumentName: Yup.string().matches(
/^[a-zA-Z0-9_]*$/,
/^(?!\s+$)[a-zA-Z0-9_ ]+$/,
"No spaces or special characters besides underscore are allowed"
),
dataType: Yup.string(),
Expand Down
4 changes: 3 additions & 1 deletion src/validations/FunctionSectionSchemaValidator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as Yup from "yup";

export const FunctionSectionSchemaValidator = Yup.object().shape({
functionName: Yup.string().required("Function name is required"),
functionName: Yup.string()
.matches(/^(?!\s+$)[a-zA-Z0-9_ ]+$/, "Function name is required")
.required("Function name is required"),
comment: Yup.string(),
fluentFunction: Yup.boolean(),
body: Yup.string(),
Expand Down
Loading