โ09-03-2024 05:02 AM
How to add validations for the fields here and display error messages when the fields are empty?
connection: { fields: [ { name: "username", hint: "Your email used for login" }, { name: "password", optional: false, control_type: "password", } ], authorization: { type: "basic_auth", credentials: lambda do |connection| user(connection["username"]) password(connection["password"]) end } }
โ09-24-2024 02:06 AM
Hi,
After reviewing your case, I suggest making the two fields required instead of validating the input upon trying to connect. This will ensure that the connector does not allow the user to connect if the fields are left empty. By making them required, the connector will automatically throw an error when it detects empty values, prompting the user to fill in the necessary information.
I hope this solution will help resolve the issue you are experiencing. If you have any further questions or concerns, please do not hesitate to reach out to us. We are always happy to assist you.
Thank you
โ11-15-2024 09:12 AM
To add validations for the fields in your connection configuration and display error messages when the fields are empty, you can incorporate conditional logic that checks for the presence of these fields before proceeding with the connection. Below is an example of how to implement this:
connection: {
fields: [
{
name: "username",
hint: "Your email used for login",
optional: false
},
{
name: "password",
optional: false,
control_type: "password"
}
],
authorization: {
type: "basic_auth",
credentials: lambda do |connection|
if connection["username"].blank? || connection["password"].blank?
raise "Username and password cannot be empty."
end
user(connection["username"])
password(connection["password"])
end
}
}