Special Methods

We've created a few special methods to help simplify your expressions.

OneOf Method

This string extension method is used to specify one or more values. It is an ideal replacement for using multiple OR (||) conditions.

Evaluate by specifying multiple employee numbers:

Employement.EmployeeNumber.OneOf('001234,005678,009876')

Evaluate by specifying source-object:

Location.LocationCode.OneOf('MIA,LAX,JFK,LGA')
Company.CompanyCity.OneOf('Miami,Los Angeles,New York')

Evaluate by specifying multiple company source-objects:

Employment.CompanyCode.OneOf("TSLA,MSFT,AMZN,META,AAPL,GOOGL")
Company.CompanyName.OneOf("Tesla,Microsoft,Amazon,Apple,Google")
 
NotOneOf Method

This string extension method is used to specify one or more values to exclude. Ideal replacement for using multiple OR (||) conditions.

Evaluate by specifying multiple employee numbers:

Employment.EmployeeNumber.NotOneOf('999901,999902,999903')

Evaluate by specifying [source-object]:

Location.LocationCode.NotOneOf('TEST,DEMO,EVAL')
Company.CompanyCity.NotOneOf('Miami,Los Angeles,New York')

Evaluate by specifying multiple company [source-object]:

Employment.CompanyCode.OneOf("ENE,LEHLQ,TWO")
Company.CompanyName.NotOneOf("Tesla,Microsoft,Amazon,Apple,Google")
 
RemoveDiacritics Method

This string extension method is used to replace diacritical characters with their equivalent non-diacritical characters.

Replace diacritic characters with non-diacritic characters:

Person.FirstName.RemoveDiacritics()

If the person's first name is Renée, it will be replaced with Renee.

If the person's first name is Amélie, it will be replaced with Amelie.

If the person's first name is Héloïse, it will be replaced with Heloise.

 
RemoveWhiteSpace Method

This string extension method is used to remove white-space from a string.

Remove white-space:

Person.LastName.RemoveWhiteSpace()

If the person's last name is Van Patten, it will be changed to VanPatten.

If the person's last name is van der Sar, it will be replaced with vanderSar.

If the person's last name is Mc Donald, it will be replaced with McDonald.

 
RemoveSpecialCharacters Method

This string extension method is used to remove special characters from a string.

Remove special characters:

Job.Title.RemoveSpecialCharacters()
Employment.JobTitle.RemoveSpecialCharacters()

If the job title is Sales & Marketing, it will be changed to Sales Marketing.

If the job title is Tech/Support, it will be changed to TechSupport.

If the job title is Finance, it will be changed to Finance.

 
RemoveWhiteSpaceSpecialCharactersDiacritics Method

This string extension method nests the RemoveWhiteSpace(), RemoveSpecialCharacters() and RemoveDiacritics() methods into a single method for ease of use.

Remove white-space, special characters and diacritics

Person.LastName.RemoveWhiteSpaceSpecialCharactersDiacritics()

If the person's last name is van der Woude's, it will be changed to vanderWoudes.

If the person's last name is Louis-Marie Lefèvre, it will be changed to LouisMarieLefevre.

 
ToTitleCase Method

This string extension method converts the specified string to title case.

Set the string to title case

Person.FirstName.ToTitleCase()

If the person's first name is JOHN, it will be changed to John.

If the person's first name is Louis marie, it will be changed to Louis Marie.

 
FirstWord Method

The FirstWord method returns the first word from a string. A "word" is defined as a sequence of characters separated by spaces.

For example:

Person.FirstName.FirstWord()

If the first name is Mary Jane, it will return Mary.

If the first name is John, it will return John.

If the first name is Jean-Luc, it will return Jean-Luc.

Please note: Hyphens and special characters within a word do not split it, only spaces do.

 
LastWord Method

The LastWord method returns the last word from a string. A "word" is defined as a sequence of characters separated by spaces.

For example:

Person.FirstName.LastWord()

If the first name is Mary Jane, it will return Jane.

If the first name is John, it will return John.

If the first name is Jean-Luc, it will return Jean-Luc.

Please note: Hyphens and special characters within a word do not split it, only spaces do.

 
FirstChars Method

The FirstChars method returns the first number of characters from a string, where the number is defined in parentheses. It’s helpful when only the beginning portion of a value is needed, such as an abbreviation, a code prefix, or surnames made of multiple words.

For example:

Job.LongTitle.FirstChars(5)

If the job title is Manager, it will return Manag.

If the job title is HR, it will return HR.

As you can see from the second example, if the number of characters requested is greater than the string length, the full string is returned.

 
LastChars Method

This string extension method returns the last number of characters from a string, based on the number defined in parentheses. It’s useful for trimming down longer values or extracting suffixes like the last digits of an ID.

For example:

Employement.EmployeeNumber.LastChars(3)

If the employee number is 123456, it will return 456.

If the employee number is 89, it will return 89.

As with FirstChars, if the number in the parentheses exceeds the string's length, the entire value is returned, as you can see in example two.

 
Generate Random Password Method

You can use GenerateRandomPassword() to return a string that can then be used for the default password for a user on account creation.

The method takes in 5 parameters which set different options for creating the password.

  • the length of the password
  • if lowercase letters should be included
  • if uppercase letters should be included
  • if numbers should be included
  • if special characters should be included

Generate a random password of length 8 that contains just lowercase letters and numbers

GenerateRandomPassword(8, true, false, true, false)

Generate a random password of length 14 that contains all types of characters

GenerateRandomPassword(14, true, true, true, true)

A value between 4 and 20 must be placed within the first parameter, a value outside that range will result in an error.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.