Skip to content

Commit b923891

Browse files
authored
docs: add datepicker dateType property to input schema (#1227)
Add new datepicker `dateType` property to input schema specification.
1 parent 97830de commit b923891

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed
93.4 KB
Loading
40.1 KB
Loading
24.8 KB
Loading

sources/platform/actors/development/actor_definition/input_schema/specification.md

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,61 @@ Rendered input:
181181

182182
![Apify Actor input schema - country input](./images/input-schema-country.png)
183183

184+
Example of date selection using absolute and relative `datepicker` editor:
185+
186+
```json
187+
{
188+
"absoluteDate": {
189+
"title": "Date",
190+
"type": "string",
191+
"description": "Select absolute date in format YYYY-MM-DD",
192+
"editor": "datepicker",
193+
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
194+
},
195+
"relativeDate": {
196+
"title": "Relative date",
197+
"type": "string",
198+
"description": "Select relative date in format +/- {number} {unit}",
199+
"editor": "datepicker",
200+
"dateType": "relative",
201+
"pattern": "^([+-])\\s*(\\d+)\\s*(day|week|month|year)s?$"
202+
},
203+
"anyDate": {
204+
"title": "Any date",
205+
"type": "string",
206+
"description": "Select date in format YYYY-MM-DD or +/- {number} {unit}",
207+
"editor": "datepicker",
208+
"dateType": "absoluteOrRelative",
209+
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$|^([+-])\\s*(\\d+)\\s*(day|week|month|year)s?$"
210+
}
211+
}
212+
```
213+
214+
The `absoluteDate` property renders a date picker that allows selection of a specific date and returns string value in `YYYY-MM-DD` format. Validation is ensured thanks to `pattern` field. In this case the `dateType` property is omitted, as it defaults to `"absolute"`.
215+
216+
![Apify Actor input schema - country input](./images/input-schema-date-absolute.png)
217+
218+
The `relativeDate` property renders an input field that enables the user to choose the relative date and returns the value in `+/- {number} {unit}` format, for example `"+ 2 days"`. The `dateType` parameter is set to `"relative"` to restrict input to relative dates only.
219+
220+
![Apify Actor input schema - country input](./images/input-schema-date-relative.png)
221+
222+
The `anyDate` property renders a date picker that accepts both absolute and relative dates. The Actor author is responsible for parsing and interpreting the selected date format.
223+
224+
![Apify Actor input schema - country input](./images/input-schema-date-both.png)
225+
184226
Properties:
185227

186-
| Property | Value | Required | Description |
187-
|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
188-
| `editor` | One of <ul><li>`textfield`</li><li>`textarea`</li><li>`javascript`</li><li>`python`</li><li>`select`</li><li>`datepicker`</li><li>`hidden`</li></ul> | Yes | Visual editor used for <br/>the input field. |
189-
| `pattern` | String | No | Regular expression that will be <br/>used to validate the input. <br/> If validation fails, <br/>the Actor will not run. |
190-
| `minLength` | Integer | No | Minimum length of the string. |
191-
| `maxLength` | Integer | No | Maximum length of the string. |
192-
| `enum` | [String] | Required if <br/>`editor` <br/>is `select` | Using this field, you can limit values <br/>to the given array of strings. <br/>Input will be displayed as select box. |
193-
| `enumTitles` | [String] | No | Titles for the `enum` keys described. |
194-
| `nullable` | Boolean | No | Specifies whether `null` <br/>is an allowed value. |
195-
| `isSecret` | Boolean | No | Specifies whether the input field<br />will be stored encrypted.<br />Only available <br />with `textfield` and `textarea` editors. |
228+
| Property | Value | Required | Description |
229+
|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
230+
| `editor` | One of <ul><li>`textfield`</li><li>`textarea`</li><li>`javascript`</li><li>`python`</li><li>`select`</li><li>`datepicker`</li><li>`hidden`</li></ul> | Yes | Visual editor used for <br/>the input field. |
231+
| `pattern` | String | No | Regular expression that will be <br/>used to validate the input. <br/> If validation fails, <br/>the Actor will not run. |
232+
| `minLength` | Integer | No | Minimum length of the string. |
233+
| `maxLength` | Integer | No | Maximum length of the string. |
234+
| `enum` | [String] | Required if <br/>`editor` <br/>is `select` | Using this field, you can limit values <br/>to the given array of strings. <br/>Input will be displayed as select box. |
235+
| `enumTitles` | [String] | No | Titles for the `enum` keys described. |
236+
| `nullable` | Boolean | No | Specifies whether `null` <br/>is an allowed value. |
237+
| `isSecret` | Boolean | No | Specifies whether the input field<br />will be stored encrypted.<br />Only available <br />with `textfield` and `textarea` editors. |
238+
| `dateType` | One of <ul><li>`absolute`</li><li>`relative`</li><li>`absoluteOrRelative`</li></ul> | No | This property, which is only available with `datepicker` editor, specifies what date format should visual editor accept (The JSON editor accepts any string without validation.).<br/><br/><ul><li>`absolute` value enables date input in `YYYY-MM-DD` format. To parse returned string regex like this can be used: `^(\d{4})-(0[1-9]\|1[0-2])-(0[1-9]\|[12]\d\|3[01])$`.</li><br/><li>`relative` value enables relative date input in <br/>`+/- {number} {unit}` format. <br/>Supported units are: days, weeks, months, years.<br/><br/>The input is passed to the Actor as plain text (e.g., "+3 weeks"). To parse it, regex like this can be used: `^([+-])\s*(\d+)\s*(day\|week\|month\|year)s?$`.</li><br/><li>`absoluteOrRelative` value enables both absolute and relative formats and user can switch between them. It's up to Actor author to parse a determine actual used format - regexes above can be used to check whether the returned string match one of them.</li></ul><br/>Defaults to `absolute`. |
196239

197240
:::note Regex escape
198241

0 commit comments

Comments
 (0)