E

4 Messages

 • 

605 Points

Tuesday, November 26th, 2024 6:47 PM

Validation Script that Checks whether Column Name and Column Description are identical

Hello, 

Can someone help me and share a validation script that checks if the description of a column is not identical to the column's name? I tried to use the below one but I failed.

rule {
    isNotEqual(attributes.'Description'?.first(), attributes.'Name'?.first(), 
        message: "The description cannot be the same as the asset name.")
}

Thanks in advance.

144 Messages

 • 

9.9K Points

25 days ago

you might prefer to solve via Given | When | Then ... Advanced validation script structure

rule {
	given {
	}
	when {   
	}
	then {
	}
}

23 Messages

 • 

1.9K Points

25 days ago

Hi @emiliawalencik1 ,

think you might need to change your validation rule from isNotEqual() to is isEqual(), because you want to display the message when the description and name are equal.

rule {
    isEqual(attributes.'Description'?.first(), attributes.'Name'?.first(), \
        message: "The description cannot be the same as the asset name.")
}

(edited)

4 Messages

 • 

605 Points

@laurenzhiller1​ Thanks. Have you tried changing the description name not to match the column name and revalidate the asset? In my case, regardless of whether the name and description match or not, the provided script always returns a false value :/

It seems like the script isn't reading the 'Name' value at all. To check this out, I tried accessing the 'Name' and 'Description' values by placing them in a message, and while the message returns the 'Description' value , the 'Name' value seems to be empty. See screenshots attached (Option 1 & 2).

23 Messages

 • 

1.9K Points

@emiliawalencik1​ I have looked at the problem again in detail and have to revise my last answer.

First of all, it is correct to use IsNotEqual, as the asset should be invalid if the condition is not fulfilled (returns false).

Secondly, the names (Full Name, Display Name) aren't attributes of the asset. Therefore, they cannot be read with attributes.'Name'. The expression attributes.'Name' returns null. If the message only contains attributes.'Name', as in your example, then nothing is printed at all, as the entire message is null.

If you combine attributes.'Name' with an additional message, you can double-check that the value is null:

Instead of using attributes.'Name' just use displayName (or name, if you want to use the full name instead). This validation script should fit your purpose:

rule {
    isNotEqual(attributes.'Description'?.first(), displayName, \
        message: "The description cannot be the same as the asset name.")
}

4 Messages

 • 

605 Points

@laurenzhiller1​ Now it works! Thank you :)

23 Messages

 • 

1.9K Points

@emiliawalencik1​ Great! You're welcome 🙂

Loading...