From 73c3b1a6296274b928db6f7c60d269e07974175a Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Sun, 12 Feb 2023 11:12:19 -0500 Subject: [PATCH] docs: update calculation example with better arg --- documentation/topics/calculations.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/documentation/topics/calculations.md b/documentation/topics/calculations.md index c38f666c..af6d2a9c 100644 --- a/documentation/topics/calculations.md +++ b/documentation/topics/calculations.md @@ -61,10 +61,14 @@ end # Usage in a resource calculations do calculate :full_name, :string, {Concat, keys: [:first_name, :last_name]} do - # You currently need to use the [allow_empty?: true, trim?: false] constraints here. + # You need to use the [allow_empty?: true, trim?: false] constraints here. # The separator could be an empty string or require a leading or trailing space, - # but would be trimmed or even set to `nil` without the constraints. - argument :separator, :string, constraints: [allow_empty?: true, trim?: false] + # but would be trimmed or even set to `nil` without the constraints shown below. + argument :separator, :string do + allow_nil? false + constraints [allow_empty?: true, trim?: false] + default "" + end end end ```