Two questions about function parameters


1- I saw on documentation that a field can be reached using the ‘context’ parameter (e.g. context.New.Phone) or by the ‘five’ parameter (e.g. five.field.Phone).
What is the difference between them, and what is the best to use ?

2- What paramater should I use if I want the value of the ‘current field’ when the function is called from an Events thrown by a Form-field (e.g field On validate)?

For example, I have many telephone number fields and I want to re-use the same function for these fields (HomePhone, PrivateMobile, BusinessMobile). In the following JS function, what should I write instead of [currentFieldValue]:

Function validatePhone (five, context, result) {
    let telephone = [currentFieldValue];
    if (telephone.length !== 10 && telephone.length !== 0) {
        return five.createError(result, 'Phone must be 10 digits');
    return five.success(result);

Hi Jean,

  1. The following will help to understand the difference between and five.field.
  1. To get the value for the current field, you can use:


This function has not been fully documented yet, however, it is a function used on the Five object that returns the sender associated with the event callback.

Function Signature
sender() : any;

So for your situation you could go:
let telephone = five.sender().value


Ok, that’s very clear, thank you !

Perfect, thanks Jean!