Skip to content

Commit a33ad75

Browse files
committed
nette/schema 1.3.2
1 parent bdde973 commit a33ad75

17 files changed

+697
-17
lines changed

schema/bg/@home.texy

+41-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault();
197197

198198
Структурите са обекти с определени ключове. Всяка от тези двойки ключ => стойност се нарича "свойство":
199199

200-
Структурите приемат масиви и обекти и връщат обекти `stdClass` (освен ако не ги промените с `castTo('array')` и т.н.).
200+
Структурите приемат масиви и обекти и връщат обекти `stdClass`.
201201

202202
По подразбиране всички свойства са незадължителни и имат стойност по подразбиране `null`. Можете да дефинирате задължителни свойства, като използвате `required()`:
203203

@@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]);
241241
// ОК, връща {'optional' => null, 'nullable' => null}
242242
```
243243

244+
Масивът от всички свойства на структурата се връща от метода `getShape()`.
245+
244246
По подразбиране във входните данни не може да има допълнителни елементи:
245247

246248
```php
@@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK
263265
$processor->process($schema, ['additional' => true]); // ОШИБКА
264266
```
265267

268+
Можете да създадете нова структура, като я извлечете от друга с помощта на `extend()`:
269+
270+
```php
271+
$dog = Expect::structure([
272+
'name' => Expect::string(),
273+
'age' => Expect::int(),
274+
]);
275+
276+
$dogWithBreed = $dog->extend([
277+
'breed' => Expect::string(),
278+
]);
279+
```
280+
281+
282+
Масив .[#toc-array]
283+
-------------------
284+
285+
Масив с дефинирани ключове. Прилагат се същите правила като за [структурите |#structure].
286+
287+
```php
288+
$schema = Expect::array([
289+
'required' => Expect::string()->required(),
290+
'optional' => Expect::string(), // default value is null
291+
]);
292+
```
293+
294+
Можете да дефинирате и индексиран масив, известен като кортеж:
295+
296+
```php
297+
$schema = Expect::array([
298+
Expect::int(),
299+
Expect::string(),
300+
Expect::bool(),
301+
]);
302+
303+
$processor->process($schema, [1, 'hello', true]); // OK
304+
```
305+
266306

267307
Остарели елементи .[#toc-ustarevsie-elementy]
268308
---------------------------------------------

schema/cs/@home.texy

+41-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Struktury
197197

198198
Struktury jsou objekty s definovanými klíči. Každá z dvojic klíč => hodnota je označována jako „vlastnost“:
199199

200-
Struktury přijímají pole a objekty a vrací objekty `stdClass` (pokud to nezměníte pomocí `castTo('array')` apod).
200+
Struktury přijímají pole a objekty a vrací objekty `stdClass`.
201201

202202
Ve výchozím nastavení jsou všechny vlastnosti volitelné a mají výchozí hodnotu `null`. Povinné vlastnosti můžete definovat pomocí `required()`:
203203

@@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]);
241241
// OK, vrací {'optional' => null, 'nullable' => null}
242242
```
243243

244+
Pole všech vlastností struktury vrací metoda `getShape()`.
245+
244246
Ve výchozím nastavení nemohou být ve vstupních datech žádné položky navíc:
245247

246248
```php
@@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK
263265
$processor->process($schema, ['additional' => true]); // CHYBA
264266
```
265267

268+
Novou strukturu můžete vytvořit odvozením od jiné pomocí `extend()`:
269+
270+
```php
271+
$dog = Expect::structure([
272+
'name' => Expect::string(),
273+
'age' => Expect::int(),
274+
]);
275+
276+
$dogWithBreed = $dog->extend([
277+
'breed' => Expect::string(),
278+
]);
279+
```
280+
281+
282+
Pole .{data-version:1.3.2}
283+
--------------------------
284+
285+
Pole s definovanými klíči. Platí pro něj vše co [struktury|#structure].
286+
287+
```php
288+
$schema = Expect::array([
289+
'required' => Expect::string()->required(),
290+
'optional' => Expect::string(), // výchozí hodnota je null
291+
]);
292+
```
293+
294+
Lze definovat také indexované pole, známé jako tuple:
295+
296+
```php
297+
$schema = Expect::array([
298+
Expect::int(),
299+
Expect::string(),
300+
Expect::bool(),
301+
]);
302+
303+
$processor->process($schema, [1, 'hello', true]); // OK
304+
```
305+
266306

267307
Zastaralé vlastnosti
268308
--------------------

schema/de/@home.texy

+41-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Strukturen .[#toc-structures]
197197

198198
Strukturen sind Objekte mit definierten Schlüsseln. Jedes dieser Schlüssel => Wert-Paare wird als "Eigenschaft" bezeichnet:
199199

200-
Strukturen akzeptieren Arrays und Objekte und geben Objekte zurück `stdClass` (es sei denn, Sie ändern dies mit `castTo('array')`, etc.).
200+
Strukturen akzeptieren Arrays und Objekte und geben Objekte zurück `stdClass`.
201201

202202
Standardmäßig sind alle Eigenschaften optional und haben einen Standardwert von `null`. Obligatorische Eigenschaften können Sie mit `required()` definieren:
203203

@@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]);
241241
// OK, liefert {'optional' => null, 'nullable' => null}
242242
```
243243

244+
Das Array mit allen Struktureigenschaften wird von der Methode `getShape()` zurückgegeben.
245+
244246
Standardmäßig können keine zusätzlichen Elemente in den Eingabedaten enthalten sein:
245247

246248
```php
@@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK
263265
$processor->process($schema, ['additional' => true]); // ERROR
264266
```
265267

268+
Sie können eine neue Struktur erstellen, indem Sie mit `extend()` von einer anderen ableiten:
269+
270+
```php
271+
$dog = Expect::structure([
272+
'name' => Expect::string(),
273+
'age' => Expect::int(),
274+
]);
275+
276+
$dogWithBreed = $dog->extend([
277+
'breed' => Expect::string(),
278+
]);
279+
```
280+
281+
282+
Array .[#toc-array]
283+
-------------------
284+
285+
Ein Array mit definierten Schlüsseln. Es gelten die gleichen Regeln wie für [Strukturen |#structure].
286+
287+
```php
288+
$schema = Expect::array([
289+
'required' => Expect::string()->required(),
290+
'optional' => Expect::string(), // default value is null
291+
]);
292+
```
293+
294+
Sie können auch ein indiziertes Array, ein sogenanntes Tupel, definieren:
295+
296+
```php
297+
$schema = Expect::array([
298+
Expect::int(),
299+
Expect::string(),
300+
Expect::bool(),
301+
]);
302+
303+
$processor->process($schema, [1, 'hello', true]); // OK
304+
```
305+
266306

267307
Verwerfungen .[#toc-deprecations]
268308
---------------------------------

schema/el/@home.texy

+41-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault();
197197

198198
Οι δομές είναι αντικείμενα με καθορισμένα κλειδιά. Κάθε ένα από αυτά τα ζεύγη κλειδί => τιμή αναφέρεται ως "ιδιότητα":
199199

200-
Οι δομές δέχονται πίνακες και αντικείμενα και επιστρέφουν αντικείμενα `stdClass` (εκτός αν το αλλάξετε με το `castTo('array')`, κ.λπ.).
200+
Οι δομές δέχονται πίνακες και αντικείμενα και επιστρέφουν αντικείμενα `stdClass`.
201201

202202
Από προεπιλογή, όλες οι ιδιότητες είναι προαιρετικές και έχουν προεπιλεγμένη τιμή `null`. Μπορείτε να ορίσετε υποχρεωτικές ιδιότητες χρησιμοποιώντας το `required()`:
203203

@@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]);
241241
// OK, επιστρέφει {'optional' => null, 'nullable' => null}
242242
```
243243

244+
Ο πίνακας όλων των ιδιοτήτων της δομής επιστρέφεται από τη μέθοδο `getShape()`.
245+
244246
Από προεπιλογή, δεν μπορούν να υπάρχουν επιπλέον στοιχεία στα δεδομένα εισόδου:
245247

246248
```php
@@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK
263265
$processor->process($schema, ['additional' => true]); // ΣΦΑΛΜΑ
264266
```
265267

268+
Μπορείτε να δημιουργήσετε μια νέα δομή παράγοντας από μια άλλη χρησιμοποιώντας το `extend()`:
269+
270+
```php
271+
$dog = Expect::structure([
272+
'name' => Expect::string(),
273+
'age' => Expect::int(),
274+
]);
275+
276+
$dogWithBreed = $dog->extend([
277+
'breed' => Expect::string(),
278+
]);
279+
```
280+
281+
282+
Συστοιχία .[#toc-array]
283+
-----------------------
284+
285+
Ένας πίνακας με καθορισμένα κλειδιά. Ισχύουν οι ίδιοι κανόνες όπως και για [τις δομές |#structure].
286+
287+
```php
288+
$schema = Expect::array([
289+
'required' => Expect::string()->required(),
290+
'optional' => Expect::string(), // default value is null
291+
]);
292+
```
293+
294+
Μπορείτε επίσης να ορίσετε έναν δεικτοδοτούμενο πίνακα, γνωστό ως πλειάδα:
295+
296+
```php
297+
$schema = Expect::array([
298+
Expect::int(),
299+
Expect::string(),
300+
Expect::bool(),
301+
]);
302+
303+
$processor->process($schema, [1, 'hello', true]); // OK
304+
```
305+
266306

267307
Αποσβέσεις .[#toc-deprecations]
268308
-------------------------------

schema/en/@home.texy

+41-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Structures
197197

198198
Structures are objects with defined keys. Each of these key => value pairs is referred to as a "property":
199199

200-
Structures accept arrays and objects and return objects `stdClass` (unless you change it with `castTo('array')`, etc.).
200+
Structures accept arrays and objects and return objects `stdClass`.
201201

202202
By default, all properties are optional and have a default value of `null`. You can define mandatory properties using `required()`:
203203

@@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]);
241241
// OK, returns {'optional' => null, 'nullable' => null}
242242
```
243243

244+
The array of all structure properties is returned by the `getShape()` method.
245+
244246
By default, there can be no extra items in the input data:
245247

246248
```php
@@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK
263265
$processor->process($schema, ['additional' => true]); // ERROR
264266
```
265267

268+
You can create a new structure by deriving from another using `extend()`:
269+
270+
```php
271+
$dog = Expect::structure([
272+
'name' => Expect::string(),
273+
'age' => Expect::int(),
274+
]);
275+
276+
$dogWithBreed = $dog->extend([
277+
'breed' => Expect::string(),
278+
]);
279+
```
280+
281+
282+
Array .{data-version:1.3.2}
283+
---------------------------
284+
285+
An array with defined keys. The same rules apply as for [structures|#structure].
286+
287+
```php
288+
$schema = Expect::array([
289+
'required' => Expect::string()->required(),
290+
'optional' => Expect::string(), // default value is null
291+
]);
292+
```
293+
294+
You can also define an indexed array, known as a tuple:
295+
296+
```php
297+
$schema = Expect::array([
298+
Expect::int(),
299+
Expect::string(),
300+
Expect::bool(),
301+
]);
302+
303+
$processor->process($schema, [1, 'hello', true]); // OK
304+
```
305+
266306

267307
Deprecations
268308
------------

schema/es/@home.texy

+41-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Estructuras .[#toc-structures]
197197

198198
Las estructuras son objetos con claves definidas. Cada uno de estos pares clave => valor se denomina "propiedad":
199199

200-
Las estructuras aceptan arrays y objetos y devuelven objetos `stdClass` (a menos que lo cambies con `castTo('array')`, etc.).
200+
Las estructuras aceptan matrices y objetos y devuelven objetos `stdClass`.
201201

202202
Por defecto, todas las propiedades son opcionales y tienen un valor por defecto de `null`. Puede definir propiedades obligatorias utilizando `required()`:
203203

@@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]);
241241
// OK, devuelve {'optional' => null, 'nullable' => null}
242242
```
243243

244+
El array de todas las propiedades de la estructura es devuelto por el método `getShape()`.
245+
244246
Por defecto, no puede haber elementos adicionales en los datos de entrada:
245247

246248
```php
@@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK
263265
$processor->process($schema, ['additional' => true]); // ERROR
264266
```
265267

268+
Puede crear una nueva estructura derivando de otra mediante `extend()`:
269+
270+
```php
271+
$dog = Expect::structure([
272+
'name' => Expect::string(),
273+
'age' => Expect::int(),
274+
]);
275+
276+
$dogWithBreed = $dog->extend([
277+
'breed' => Expect::string(),
278+
]);
279+
```
280+
281+
282+
Matriz .[#toc-array]
283+
--------------------
284+
285+
Un array con claves definidas. Se aplican las mismas reglas que para [las estructuras |#structure].
286+
287+
```php
288+
$schema = Expect::array([
289+
'required' => Expect::string()->required(),
290+
'optional' => Expect::string(), // default value is null
291+
]);
292+
```
293+
294+
También puedes definir una matriz indexada, conocida como tupla:
295+
296+
```php
297+
$schema = Expect::array([
298+
Expect::int(),
299+
Expect::string(),
300+
Expect::bool(),
301+
]);
302+
303+
$processor->process($schema, [1, 'hello', true]); // OK
304+
```
305+
266306

267307
Depreciaciones .[#toc-deprecations]
268308
-----------------------------------

0 commit comments

Comments
 (0)