How do you use Partial functions?

Hey,

I've been wondering about how partial functions can be used in Appian. 

One thing that I was looking at was sticking a bunch of them together to define validation functions by passing them as arguments like this: 

a!textField(
  value: local!value,
  saveInto: local!value,
  validations: rule!BLAKEJ3_Validation_Composer(
    rules: {
      rule!BLAKEJ3_Validation_TextIsLongerThan10Chars(_),
      rule!BLAKEJ3_Validation_TextIsShorterThanGivenLength(fieldLength:25, input:_),  
      rule!BLAKEJ3_Validation_TextMustEndInFullStop(_),
      rule!BLAKEJ3_Validation_ApplyBySentence(
        rules: rule!BLAKEJ3_Validation_SentenceMustStartWithCapital(_), input: _
      )
    },
    input: local!value
  )
)

This seems like it can be very readable and it breaks testing down into smaller bits that can have defined test cases in expression rules. It means that new validation rules can be assembled from shared modular rule components. However I'm also wondering if its over engineering for the vast majority of cases and if most validation is such simple functions that those aren't really relevant benefits.

I'm curious for more opinions about this as well as hearing how other people have used a very uncommon Appian function.

E: This crashes every time I try and add a tag Disappointed

  Discussion posts and replies are publicly visible

Parents
  • Just looking at your rule above, I'm not sure partial evaluation is necessary. Instead, you can just plug in your input directly into the validations like this:

    a!textField(
      value: local!value,
      saveInto: local!value,
      validations: {
          rule!BLAKEJ3_Validation_TextIsLongerThan10Chars(local!value),
          rule!BLAKEJ3_Validation_TextIsShorterThanGivenLength(fieldLength:25, input:local!value),  
          rule!BLAKEJ3_Validation_TextMustEndInFullStop(local!value),
          rule!BLAKEJ3_Validation_ApplyBySentence(
            rules: rule!BLAKEJ3_Validation_SentenceMustStartWithCapital(local!value)
          )
        },
      )
    )

    Partial evaluation was used more frequently with some legacy functions like apply(), but now it's almost never used. The only times I have used it recently is for things like searching within a picker: https://docs.appian.com/suite/help/latest/recipe-configure-an-array-picker.html 

  • What kind of monster tries to make me write local!value so many times? Smiling imp

    Yes I could do that, however it is more boring. And I'm doing this to explore what I can do rather than what I'd normally do. Stuck out tongue

Reply Children
No Data