diff --git a/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-absolute.png b/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-absolute.png new file mode 100644 index 0000000000..b947633f3b Binary files /dev/null and b/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-absolute.png differ diff --git a/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-both.png b/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-both.png new file mode 100644 index 0000000000..3f9e8c8b99 Binary files /dev/null and b/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-both.png differ diff --git a/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-relative.png b/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-relative.png new file mode 100644 index 0000000000..cfc06a64fd Binary files /dev/null and b/sources/platform/actors/development/actor_definition/input_schema/images/input-schema-date-relative.png differ diff --git a/sources/platform/actors/development/actor_definition/input_schema/specification.md b/sources/platform/actors/development/actor_definition/input_schema/specification.md index 64fdd51569..b19f9d2ffd 100644 --- a/sources/platform/actors/development/actor_definition/input_schema/specification.md +++ b/sources/platform/actors/development/actor_definition/input_schema/specification.md @@ -181,18 +181,61 @@ Rendered input: ![Apify Actor input schema - country input](./images/input-schema-country.png) +Example of date selection using absolute and relative `datepicker` editor: + +```json +{ + "absoluteDate": { + "title": "Date", + "type": "string", + "description": "Select absolute date in format YYYY-MM-DD", + "editor": "datepicker", + "pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$" + }, + "relativeDate": { + "title": "Relative date", + "type": "string", + "description": "Select relative date in format +/- {number} {unit}", + "editor": "datepicker", + "dateType": "relative", + "pattern": "^([+-])\\s*(\\d+)\\s*(day|week|month|year)s?$" + }, + "anyDate": { + "title": "Any date", + "type": "string", + "description": "Select date in format YYYY-MM-DD or +/- {number} {unit}", + "editor": "datepicker", + "dateType": "absoluteOrRelative", + "pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$|^([+-])\\s*(\\d+)\\s*(day|week|month|year)s?$" + } +} +``` + +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"`. + +![Apify Actor input schema - country input](./images/input-schema-date-absolute.png) + +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. + +![Apify Actor input schema - country input](./images/input-schema-date-relative.png) + +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. + +![Apify Actor input schema - country input](./images/input-schema-date-both.png) + Properties: -| Property | Value | Required | Description | -|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------| -| `editor` | One of | Yes | Visual editor used for
the input field. | -| `pattern` | String | No | Regular expression that will be
used to validate the input.
If validation fails,
the Actor will not run. | -| `minLength` | Integer | No | Minimum length of the string. | -| `maxLength` | Integer | No | Maximum length of the string. | -| `enum` | [String] | Required if
`editor`
is `select` | Using this field, you can limit values
to the given array of strings.
Input will be displayed as select box. | -| `enumTitles` | [String] | No | Titles for the `enum` keys described. | -| `nullable` | Boolean | No | Specifies whether `null`
is an allowed value. | -| `isSecret` | Boolean | No | Specifies whether the input field
will be stored encrypted.
Only available
with `textfield` and `textarea` editors. | +| Property | Value | Required | Description | +|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `editor` | One of | Yes | Visual editor used for
the input field. | +| `pattern` | String | No | Regular expression that will be
used to validate the input.
If validation fails,
the Actor will not run. | +| `minLength` | Integer | No | Minimum length of the string. | +| `maxLength` | Integer | No | Maximum length of the string. | +| `enum` | [String] | Required if
`editor`
is `select` | Using this field, you can limit values
to the given array of strings.
Input will be displayed as select box. | +| `enumTitles` | [String] | No | Titles for the `enum` keys described. | +| `nullable` | Boolean | No | Specifies whether `null`
is an allowed value. | +| `isSecret` | Boolean | No | Specifies whether the input field
will be stored encrypted.
Only available
with `textfield` and `textarea` editors. | +| `dateType` | One of | 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.).


Defaults to `absolute`. | :::note Regex escape