Skip to content

Commit ea83f51

Browse files
xDeSwaKocal
authored andcommitted
Fix RST documentation formatting
1 parent 7c93466 commit ea83f51

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

src/LiveComponent/CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
## 2.28.0
44

55
- Add new modifiers for input validations, useful to prevent uneccessary HTTP requests:
6-
- `min_length(n)` and `max_length(n)`: validate length from textual input elements
7-
- `min_value(Nn` and `max_value(n)`: validate value from numeral input elements
6+
- `min_length` and `max_length`: validate length from textual input elements
7+
- `min_value` and `max_value`: validate value from numeral input elements
88

99
```twig
10-
<input data-model="min_length(3)|debounce(300)|name" type="text">
10+
<!-- Do not trigger model update until 3 characters are typed -->
11+
<input data-model="min_length(3)|username" type="text" value="" />
12+
13+
<!-- Only trigger updates when value number is between 10 and 100 -->
14+
<input data-model="min_value(10)|max_value(100)|quantity" type="number" value="20" />
1115
```
1216

1317
## 2.27.0

src/LiveComponent/assets/test/Directive/get_model_binding.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import getModelBinding from '../../src/Directive/get_model_binding';
44
describe('get_model_binding', () => {
55
it('returns correctly with simple directive', () => {
66
const directive = parseDirectives('firstName')[0];
7+
78
expect(getModelBinding(directive)).toEqual({
89
modelName: 'firstName',
910
innerModelName: null,
@@ -19,6 +20,7 @@ describe('get_model_binding', () => {
1920

2021
it('returns all modifiers correctly', () => {
2122
const directive = parseDirectives('on(change)|norender|debounce(100)|firstName')[0];
23+
2224
expect(getModelBinding(directive)).toEqual({
2325
modelName: 'firstName',
2426
innerModelName: null,
@@ -34,6 +36,7 @@ describe('get_model_binding', () => {
3436

3537
it('parses the parent:inner model name correctly', () => {
3638
const directive = parseDirectives('firstName:first')[0];
39+
3740
expect(getModelBinding(directive)).toEqual({
3841
modelName: 'firstName',
3942
innerModelName: 'first',
@@ -49,6 +52,7 @@ describe('get_model_binding', () => {
4952

5053
it('parses min_length and max_length modifiers', () => {
5154
const directive = parseDirectives('min_length(3)|max_length(20)|username')[0];
55+
5256
expect(getModelBinding(directive)).toEqual({
5357
modelName: 'username',
5458
innerModelName: null,
@@ -64,6 +68,7 @@ describe('get_model_binding', () => {
6468

6569
it('parses min_value and max_value modifiers', () => {
6670
const directive = parseDirectives('min_value(18)|max_value(65)|age')[0];
71+
6772
expect(getModelBinding(directive)).toEqual({
6873
modelName: 'age',
6974
innerModelName: null,
@@ -79,6 +84,7 @@ describe('get_model_binding', () => {
7984

8085
it('handles mixed modifiers correctly', () => {
8186
const directive = parseDirectives('on(change)|norender|debounce(100)|min_value(18)|max_value(65)|age:years')[0];
87+
8288
expect(getModelBinding(directive)).toEqual({
8389
modelName: 'age',
8490
innerModelName: 'years',
@@ -95,6 +101,7 @@ describe('get_model_binding', () => {
95101
it('handles empty modifier values gracefully', () => {
96102
const directive = parseDirectives('min_length|max_length|username')[0];
97103
const binding = getModelBinding(directive);
104+
98105
expect(binding.minLength).toBeNull();
99106
expect(binding.maxLength).toBeNull();
100107
});

src/LiveComponent/doc/index.rst

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -388,18 +388,14 @@ Input Model Validation Modifiers
388388
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
389389

390390
.. versionadded:: 2.28
391-
Modifiers to validate ``<input>`` value were added in UX LiveComponent 2.28.
392-
393-
When binding data using the ``data-model`` directive, you can apply input validation modifiers such as:
394391

395-
- ``min_length(<value>)``: Ensures the input length is at least the given number of characters.
396-
- ``max_length(<value>)``: Ensures the input length does not exceed the given number of characters.
397-
- ``min_value(<value>)``: Ensures the input value is not less than the given numeric value.
398-
- ``max_value(<value>)``: Ensures the input value is not greater than the given numeric value.
392+
Modifiers to validate ``<input>`` value were added in UX LiveComponent 2.28.
399393

400-
These modifiers help reduce unnecessary server requests and provide a lightweight form of frontend validation. For example:
394+
Input model validation modifiers help to reduce unnecessary server requests and provide
395+
a lightweight form of frontend validation, for example:
401396

402397
.. code-block:: html
398+
403399
<!-- Do not trigger model update until 3 characters are typed -->
404400
<input data-model="min_length(3)|username" type="text" value="" />
405401

@@ -409,7 +405,8 @@ These modifiers help reduce unnecessary server requests and provide a lightweigh
409405
``min_length``
410406
..............
411407

412-
Validate that an ``<input>`` element of type ``text``, ``email``, ``password``, ``search``, ``url`` or a ``<textarea>`` element has a value length not less than the specified length:
408+
Validate that an ``<input>`` element of type ``text``, ``email``, ``password``, ``search``, ``url``
409+
or a ``<textarea>`` element, has a value length not less than the specified length:
413410

414411
.. code-block:: html
415412

@@ -419,31 +416,32 @@ Validate that an ``<input>`` element of type ``text``, ``email``, ``password``,
419416
``max_length``
420417
..............
421418

422-
Validate that an ``<input>`` element of type ``text``, ``email``, ``password``, ``search``, ``url`` or a ``<textarea>`` element has a value length not less than the specified length:
419+
Validate that an ``<input>`` element of type ``text``, ``email``, ``password``, ``search``, ``url``
420+
or a ``<textarea>`` element, has a value length not higher than the specified length:
423421

424422
.. code-block:: html
425423

426424
<!-- Validates that the username is not longer than 10 characters -->
427425
<input type="text" data-model="max_length(10)|username">
428426

429427
``min_value``
430-
..............
428+
.............
431429

432-
Validate that an ``<input>`` element of type ``number`` or ``range`` has a numeric value which should not be less than the specific value:
430+
Validate that an ``<input>`` element of type ``number`` or ``range`` has a numeric value which is not less than the specified value:
433431

434432
.. code-block:: html
435433

436-
<!-- Validate the age is not less than 18 -->
434+
<!-- Validate that the age is not less than 18 -->
437435
<input type="number" data-model="min_value(18)|age">
438436

439437
``max_value``
440-
..............
438+
.............
441439

442-
Validate that an ``<input>`` element of type ``number`` or ``range`` has a numeric value which should not be higher than the specific value:
440+
Validate that an ``<input>`` element of type ``number`` or ``range`` has a numeric value which is not higher than the specified value:
443441

444442
.. code-block:: html
445443

446-
<!-- Validate the year is not higher than 2025 -->
444+
<!-- Validate that the year is not higher than 2025 -->
447445
<input type="number" data-model="max_value(2025)|year">
448446

449447
Forcing a Re-Render Explicitly

0 commit comments

Comments
 (0)