Skip to content

Commit 98971ea

Browse files
Merge pull request #1 from GuySartorelli/feat/small-changes
Some code quality changes
2 parents 79f19a2 + 1df6657 commit 98971ea

39 files changed

+262
-221
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Any feature requests or recommendations should be raised as [an issue](https://g
1111
This module adheres to [the Silverstripe module standards](https://docs.silverstripe.org/en/4/developer_guides/extending/modules/#module-standard)
1212
Commit messages should be [semantic](https://seesparkbox.com/foundry/semantic_commit_messages), though the style used for this module differs from that reference in the following ways:
1313

14-
- The first letter after the commit type is capitalised.
15-
- A fullstop is placed at the end of the commit message.
14+
- The first letter after the commit type is capitalized.
15+
- A full stop is placed at the end of the commit message.
1616

1717
Make sure you also read over [the resources docs](docs/en/00-resources.md) before committing any javascript.

README.md

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Thank you to [Signify](https://github.com/signify-nz) for making this module pos
44

55
This module probices a number of reusable composable validators (including AJAX validation) for use both in the CMS and in frontend forms.
66

7-
Make sure you check out the [extensions documentation](docs/en/02-extensions.md) at a minimum - some of these should be applied in almost all projects using this module.
7+
Make sure you check out the [extensions documentation][0] at a minimum - some of these should be applied in almost all projects using this module.
88

9-
If your project has any automated client-side tests, or you are implementing a validator to be compatible with this module, please make sure you read the [client side tests documentation](docs/en/03-client-side-tests.md).
9+
If your project has any automated client-side tests, or you are implementing a validator to be compatible with this module, please make sure you read the [client side tests documentation][1].
1010

1111
## Install
1212

13-
Install via [composer](https://getcomposer.org):
13+
Install via [composer][2]:
1414

1515
```bash
1616
composer require guysartorelli/silverstripe-composable-validators
@@ -22,35 +22,59 @@ composer require guysartorelli/silverstripe-composable-validators
2222

2323
The `AjaxCompositeValidator` adds a submit handler to your form. This doesn't always interact well with other submit handlers, and can result in either front-end validation being skipped or the form not submitting the way you expect it to, depending on which submit handler gets the event first. For best results, don't add additional submit handlers to the form.
2424

25-
If you're using the `AjaxCompositeValidator` on a form that uses [undefinedoffset/silverstripe-nocaptcha](https://github.com/UndefinedOffset/silverstripe-nocaptcha) 2.3.0 or higher, you should disable form submission handling for the `NocaptchaField` in that form (see instructions in the nocaptcha docs).
25+
If you're using the `AjaxCompositeValidator` on a form that uses [undefinedoffset/silverstripe-nocaptcha][3] 2.3.0 or higher, you should disable form submission handling for the `NocaptchaField` in that form (see instructions in the nocaptcha docs).
2626

27-
## [Available Validators](docs/en/01-validators.md)
27+
## [Available Validators][4]
2828

29-
- **[AjaxCompositeValidator](docs/en/01-validators.md#ajaxcompositevalidator)**
30-
Subclass of [CompositeValidator](https://api.silverstripe.org/4/SilverStripe/Forms/CompositeValidator.html) that provides AJAX validation. Resolves [an issue with losing data](https://github.com/silverstripe/silverstripe-elemental/issues/764), faster turn-around for fixing validation problems, and provides a way to use the same validation for 'client-side' validation of frontend forms.
31-
- **[SimpleFieldsValidator](docs/en/01-validators.md#simplefieldsvalidator)**
32-
Ensures the internal validation of form fields by calling `validate` on them.
33-
- **[RequiredFieldsValidator](docs/en/01-validators.md#requiredfieldsvalidator)**
34-
Like Silverstripe's [RequiredFields](https://api.silverstripe.org/4/SilverStripe/Forms/RequiredFields.html) validator, but more convenient for use in a `CompositeValidator`.
35-
- **[WarningFieldsValidator](docs/en/01-validators.md#warningfieldsvalidator)**
29+
- **[`AjaxCompositeValidator`][5]**
30+
Subclass of [`CompositeValidator`][6] that provides AJAX validation. Resolves [an issue with losing data][7], faster turn-around for fixing validation problems, and provides a way to use the same validation for 'client-side' validation of frontend forms.
31+
- **[`SimpleFieldsValidator`][8]**
32+
Ensures the internal validation of form fields by calling `validate()` on them.
33+
- **[`RequiredFieldsValidator`][9]**
34+
Like Silverstripe's [`RequiredFields`][10] validator, but more convenient for use in a `CompositeValidator`.
35+
- **[`WarningFieldsValidator`][11]**
3636
Displays a warning if some field(s) doesn't have a value. Useful for alerting users about data that is technically valid but may not provide the results they expect
37-
- **[DependentRequiredFieldsValidator](docs/en/01-validators.md#dependentrequiredfieldsvalidator)**
38-
Uses [SearchFilters](https://docs.silverstripe.org/en/4/developer_guides/model/searchfilters/) to define fields as required conditionally, based on the values of other fields (e.g. only required if `OtherField` has a value greater than 25).
39-
- **[RequiredBlocksValidator](docs/en/01-validators.md#requiredblocksvalidator)**
40-
Require a specific [elemental block(s)](https://github.com/silverstripe/silverstripe-elemental) to exist in the `ElementalArea`, with optional minimum and maximum numbers of blocks and optional positional validation.
41-
- **[RegexFieldsValidator](docs/en/01-validators.md#regexfieldsvalidator)**
37+
- **[`DependentRequiredFieldsValidator`][12]**
38+
Uses [`SearchFilter`s][13] to define fields as required conditionally, based on the values of other fields (e.g. only required if `OtherField` has a value greater than 25).
39+
- **[`RequiredBlocksValidator`][14]**
40+
Require a specific [elemental block(s)][15] to exist in the `ElementalArea`, with optional minimum and maximum numbers of blocks and optional positional validation.
41+
- **[`RegexFieldsValidator`][16]**
4242
Ensure some field(s) matches a specified regex pattern.
4343

44-
### [Abstract Validators](docs/en/01-validators.md#abstract-validators)
44+
### [Abstract Validators][17]
4545

46-
- **[BaseValidator](docs/en/01-validators.md#basevalidator)**
46+
- **[`BaseValidator`][18]**
4747
Includes methods useful for getting the actual `FormField` and its label.
48-
- **[FieldHasValueValidator](docs/en/01-validators.md#fieldhasvaluevalidator)**
48+
- **[`FieldHasValueValidator`][19]**
4949
Subclass of `BaseValidator`. Useful for validators that require logic to check if a field has any value or not.
5050

51-
## [Traits](docs/en/01-validators.md#traits)
51+
## [Traits][20]
5252

53-
- **[ValidatesMultipleFields](docs/en/01-validators.md#validatesmultiplefields)**
53+
- **[`ValidatesMultipleFields`][21]**
5454
Useful for validators that can be fed an array of field names to be validated.
55-
- **[ValidatesMultipleFieldsWithConfig](docs/en/01-validators.md#validatesmultiplefieldswithconfig)**
56-
Like ValidatesMultipleFields but requires a configuration array for each field to be validated.
55+
- **[`ValidatesMultipleFieldsWithConfig`][22]**
56+
Like `ValidatesMultipleFields` but requires a configuration array for each field to be validated.
57+
58+
[0]: docs/en/02-extensions.md
59+
[1]: docs/en/03-client-side-tests.md
60+
[2]: https://getcomposer.org
61+
[3]: https://github.com/UndefinedOffset/silverstripe-nocaptcha
62+
[4]: docs/en/01-validators.md
63+
[5]: docs/en/01-validators.md#ajaxcompositevalidator
64+
[6]: https://api.silverstripe.org/4/SilverStripe/Forms/CompositeValidator.html
65+
[7]: https://github.com/silverstripe/silverstripe-elemental/issues/764
66+
[8]: docs/en/01-validators.md#simplefieldsvalidator
67+
[9]: docs/en/01-validators.md#requiredfieldsvalidator
68+
[10]: https://api.silverstripe.org/4/SilverStripe/Forms/RequiredFields.html
69+
[11]: docs/en/01-validators.md#warningfieldsvalidator
70+
[12]: docs/en/01-validators.md#dependentrequiredfieldsvalidator
71+
[13]: https://docs.silverstripe.org/en/4/developer_guides/model/searchfilters/
72+
[14]: docs/en/01-validators.md#requiredblocksvalidator
73+
[15]: https://github.com/silverstripe/silverstripe-elemental
74+
[16]: docs/en/01-validators.md#regexfieldsvalidator
75+
[17]: docs/en/01-validators.md#abstract-validators
76+
[18]: docs/en/01-validators.md#basevalidator
77+
[19]: docs/en/01-validators.md#fieldhasvaluevalidator
78+
[20]: docs/en/01-validators.md#traits
79+
[21]: docs/en/01-validators.md#validatesmultiplefields
80+
[22]: docs/en/01-validators.md#validatesmultiplefieldswithconfig

0 commit comments

Comments
 (0)