pcfguidewiregosu

Guidewire - Adding numeric validation for Phone Number text field in PCF


I am looking to add validation to a Guidewire PCF field that checks to ensure that only numeric values are used in a Phone Number text field.


Solution

  • In InsuranceSuite, for a consistent user experience & data persistence, it’s better to validate at the entity level using field validators. If you set the entity to a validator of “phone”, there is already out of the box functionality to handle it. Though you may want to dial it in if it’s allowing international numbers that your operations do not support.

    This can be set on the entity with something like

    <column desc="Value" name="Value" nullok="false" type="varchar">
     <columnParam name="size" value="60"/>
     <columnParam
      name="validator"
      value="Phone"/>
    </column>
    

    There is an out of the box field validator for phone. See the file fieldvalidators.xml (global or locale specific). If you need a prompt, you can set the input-mask setting on the ValidatorDef node.

    <ValidatorDef description="Validator.Phone" name="Phone" 
    validation-type="gosu" value="gw.api.validation.PhoneValidator"/>
    

    You can learn more about field validators in Guidewire Documentation (you may need to log in to access): https://docs.guidewire.com/cloud/pc/202302/config/config/topics/c_pe2206236.html