Functions With Context
Functions With Context
When Inbuilt functions are called on identifier with dot the expression is passed as the first argument. below is the syntax for each function with context
- - now:
<Variable as Date Format>.now()Example:format.now() - - add:
<Variable as First Number>.add(<Expressions as Subsequent Numbers separated by comma>)Example:number.add(4,5,6) - - captcha:
<Variable as Length of Captch String>.captcha()Example:captcha_string.captcha() - - mod:
<Variable as First Number>.mod(<Expression as Second Number>)Example:number.mod(4) - - ceil:
<Variable as Number to ceil>.ceil()Example:number.ceil() - - floor:
<Variable as Number to floor>.floor()Example:number.floor() - - round:
<Variable as Number to round>.round(<Expression as Number of Decimal Places>)Example:number.round(3) - - cint:
<Variable as Number to convert to Integer>.cint()Example:number.cint() - - sub:
<Variable as First Number>.sub(<Expression as Second Number>)Example:number.sub(4) - - mul:
<Variable as First Number>.mul(<Expressions as Subsequent Numbers separated by comma>)Example:number.mul(4,5,6) - - div:
<Variable as First Number>.div(<Expression as Second Number>)Example:number.div(2) - - concat:
<Variable as First String>.concat(<Expressions as Subsequent Strings separated by comma>)Example:prefix.concat("World ","There") - - lpad:
<Variable as String to be padded>.lpad(<Expression as String to pad>,<Expression as Final Length>)Example:number.lpad("0",5) - - rpad:
<Variable as String to be padded>.rpad(<Expression as String to pad>,<Expression as Final Length>)Example:number.rpad("0",5) - - mid:
<Variable as String to be taken from>.mid(<Expression as From Index>,<Expression as Length>)Example:string_to_mid.mid(2,3) - - left:
<Variable as String to be taken from>.left(<Expression as Length>)Example:string_to_left.left(3) - - right:
<Variable as String to be taken from>.right(<Expression as Length>)Example:string_to_right.right(3) - - from_json:
<Variable as Path of file>.from_json()Example:path.from_jason() - - fake:
<Variable as Type of Fake Field>.fake()Example:field.fake(), Following Fake Field Types Supported- - "Name"
- - "FirstName"
- - "LastName"
- - "Title"
- - "Suffix"
- - "NameWithTitle"
- - "CompanySuffix"
- - "CompanyName"
- - "Profession"
- - "CityName"
- - "StreetName"
- - "StateName"
- - "StateAbbr"
- - "ZipCode"
- - encode:
<Variable as String to be encoded>.encode()Example:string_to_encode.encode() - - random:
<Variable as Numeric Lower Bound>.random(<Expression as Numeric Upper Bound>)Example:lower_bound.random(300) - - array:
<Variable as Numeric Length of Array>.array(<Expression to be evaluated while populating each element>)Example:array_length.array("FirstName".fake()) - - unique_random_elements:
<Variable as Numeric Length of Array>.unique_random_elements(<Expression as Array from where elements to take>)Example:number_of_elements.unique_random_elements(object [1,2,3,4,5,6,7,8,9]) - - contains:
<Variable as String to be checked>.concat(<Expression as String to check>)Example:string_to_search.contains("ara") - - random_element:
<Variable as Array from where element to take>.random_element()Example:array_to_pick_from.random_element()