mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-13 11:37:46 +02:00
refactor(plugins): create Field objects per field type in settings forms + handle rendering in class
update manifest.schema.json to have defaultValue type differ based on field type
This commit is contained in:
parent
d3a98db6d0
commit
34be5bccab
48 changed files with 3875 additions and 2553 deletions
8
docs/src/content.config.ts
Normal file
8
docs/src/content.config.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { defineCollection } from "astro:content";
|
||||
import { docsLoader, i18nLoader } from "@astrojs/starlight/loaders";
|
||||
import { docsSchema, i18nSchema } from "@astrojs/starlight/schema";
|
||||
|
||||
export const collections = {
|
||||
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
|
||||
i18n: defineCollection({ loader: i18nLoader(), schema: i18nSchema() }),
|
||||
};
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
import { defineCollection } from "astro:content";
|
||||
import { docsSchema, i18nSchema } from "@astrojs/starlight/schema";
|
||||
|
||||
export const collections = {
|
||||
docs: defineCollection({ schema: docsSchema() }),
|
||||
i18n: defineCollection({ type: "data", schema: i18nSchema() }),
|
||||
};
|
||||
|
|
@ -101,17 +101,18 @@ each property being a field key and the value being a `Field` object.
|
|||
|
||||
A field is a form element:
|
||||
|
||||
| Property | Type | Note |
|
||||
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| `type` | `checkbox` \| `datetime` \| `email` \| `group` \| `html` \| `markdown` \| `number` \| `radio-group` \| `rss` \| `select-multiple` \| `select` \| `text` \| `textarea` \| `toggler` \| `url` | Default is `text` |
|
||||
| `label` (required) | `string` | Can be translated (see i18n) |
|
||||
| `hint` | `string` | Can be translated (see i18n) |
|
||||
| `helper` | `string` | Can be translated (see i18n) |
|
||||
| `defaultValue` | `string` | You can specify multiple comma separated values for `select-multiple` |
|
||||
| `optional` | `boolean` | Default is `false` |
|
||||
| `options` | `Options` | Required for `radio-group`, `select-multiple`, and `select` types. |
|
||||
| `multiple` | `boolean` | Default is `false` |
|
||||
| `fields` | `Array<string, Field>` | Required for `group` type |
|
||||
| Property | Type | Note |
|
||||
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| `type` | `checkbox`, `datetime`, `email`, `group`, `html`, `markdown`, `number`, `radio-group`, `rss`, `select-multiple`, `select`, `text`, `textarea`, `toggler`, `url` | Default is `text` |
|
||||
| `label` (required) | `string` | Can be translated (see i18n) |
|
||||
| `hint` | `string` | Can be translated (see i18n) |
|
||||
| `helper` | `string` | Can be translated (see i18n) |
|
||||
| `defaultValue` | `string` | You can specify multiple comma separated values for `select-multiple` |
|
||||
| `validationRules` | `string` \| `array` | See [available validation rules](#available-validation-rules) |
|
||||
| `optional` | `boolean` | Default is `false` |
|
||||
| `options` | `Options` | Required for `radio-group`, `select-multiple`, and `select` types. |
|
||||
| `multiple` | `boolean` | Default is `false` |
|
||||
| `fields` | `Array<string, Field>` | Required for `group` type |
|
||||
|
||||
#### Options object
|
||||
|
||||
|
|
@ -133,3 +134,35 @@ plugin is installed.
|
|||
|
||||
Repository where the plugin's code lives. Helpful for people who want to
|
||||
contribute.
|
||||
|
||||
#### Available validation rules
|
||||
|
||||
The following rules are a subset of
|
||||
[CodeIgniter4's validation rules](https://codeigniter.com/user_guide/libraries/validation.html#available-rules).
|
||||
|
||||
| Rule | Parameter | Description | Example |
|
||||
| --------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
|
||||
| alpha | No | Fails if field has anything other than alphabetic characters in ASCII. | |
|
||||
| alpha_dash | No | Fails if field contains anything other than alphanumeric characters, underscores or dashes in ASCII. | |
|
||||
| alpha_numeric | No | Fails if field contains anything other than alphanumeric characters in ASCII. | |
|
||||
| alpha_numeric_punct | No | Fails if field contains anything other than alphanumeric, space, or this limited set of punctuation characters: `~` (tilde), `!` (exclamation), `#` (number), `$` (dollar), `%` (percent), `&` (ampersand), `*` (asterisk), `-` (dash), `_` (underscore), `+` (plus), `=` (equals), `\|` (vertical bar),`:`(colon),`.` (period). | |
|
||||
| alpha_numeric_space | No | Fails if field contains anything other than alphanumeric or space characters in ASCII. | |
|
||||
| alpha_space | No | Fails if field contains anything other than alphabetic characters or spaces in ASCII. | |
|
||||
| decimal | No | Fails if field contains anything other than a decimal number. Also accepts a `+` or `-` sign for the number. | |
|
||||
| differs | Yes | Fails if field does not differ from the one in the parameter. | `differs[field_name]` |
|
||||
| exact_length | Yes | Fails if field length is not exactly the parameter value. One or more comma-separated values are possible. | `exact_length[5]` or `exact_length[5,8,12]` |
|
||||
| greater_than | Yes | Fails if field is less than or equal to the parameter value or not numeric. | `greater_than[8]` |
|
||||
| greater_than_equal_to | Yes | Fails if field is less than the parameter value, or not numeric. | `greater_than_equal_to[5]` |
|
||||
| hex | No | Fails if field contains anything other than hexadecimal characters. | |
|
||||
| in_list | Yes | Fails if field is not within a predetermined list. | `in_list[red,blue,green]` |
|
||||
| integer | No | Fails if field contains anything other than an integer. | |
|
||||
| is_natural | No | Fails if field contains anything other than a natural number: `0`, `1`, `2`, `3`, etc. | |
|
||||
| is_natural_no_zero | No | Fails if field contains anything other than a natural number, except zero: `1`, `2`, `3`, etc. | |
|
||||
| less_than | Yes | Fails if field is greater than or equal to the parameter value or not numeric. | `less_than[8]` |
|
||||
| less_than_equal_to | Yes | Fails if field is greater than the parameter value or not numeric. | `less_than_equal_to[8]` |
|
||||
| max_length | Yes | Fails if field is longer than the parameter value. | `max_length[8]` |
|
||||
| min_length | Yes | Fails if field is shorter than the parameter value. | `min_length[3]` |
|
||||
| not_in_list | Yes | Fails if field is within a predetermined list. | `not_in_list[red,blue,green]` |
|
||||
| regex_match | Yes | Fails if field does not match the regular expression. | `regex_match[/regex/]` |
|
||||
| valid_base64 | No | Fails if field contains anything other than valid Base64 characters. | |
|
||||
| valid_date | Yes | Fails if field does not contain a valid date. Any string that `strtotime()` accepts is valid if you don't specify an optional parameter that matches a date format. | `valid_date[d/m/Y]` |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue