Skip to content

Commit

Permalink
nette/schema 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 6, 2024
1 parent bdde973 commit a33ad75
Show file tree
Hide file tree
Showing 17 changed files with 697 additions and 17 deletions.
42 changes: 41 additions & 1 deletion schema/bg/@home.texy
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault();

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

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

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

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

Масивът от всички свойства на структурата се връща от метода `getShape()`.

По подразбиране във входните данни не може да има допълнителни елементи:

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

Можете да създадете нова структура, като я извлечете от друга с помощта на `extend()`:

```php
$dog = Expect::structure([
'name' => Expect::string(),
'age' => Expect::int(),
]);

$dogWithBreed = $dog->extend([
'breed' => Expect::string(),
]);
```


Масив .[#toc-array]
-------------------

Масив с дефинирани ключове. Прилагат се същите правила като за [структурите |#structure].

```php
$schema = Expect::array([
'required' => Expect::string()->required(),
'optional' => Expect::string(), // default value is null
]);
```

Можете да дефинирате и индексиран масив, известен като кортеж:

```php
$schema = Expect::array([
Expect::int(),
Expect::string(),
Expect::bool(),
]);

$processor->process($schema, [1, 'hello', true]); // OK
```


Остарели елементи .[#toc-ustarevsie-elementy]
---------------------------------------------
Expand Down
42 changes: 41 additions & 1 deletion schema/cs/@home.texy
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Struktury

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

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

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

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

Pole všech vlastností struktury vrací metoda `getShape()`.

Ve výchozím nastavení nemohou být ve vstupních datech žádné položky navíc:

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

Novou strukturu můžete vytvořit odvozením od jiné pomocí `extend()`:

```php
$dog = Expect::structure([
'name' => Expect::string(),
'age' => Expect::int(),
]);

$dogWithBreed = $dog->extend([
'breed' => Expect::string(),
]);
```


Pole .{data-version:1.3.2}
--------------------------

Pole s definovanými klíči. Platí pro něj vše co [struktury|#structure].

```php
$schema = Expect::array([
'required' => Expect::string()->required(),
'optional' => Expect::string(), // výchozí hodnota je null
]);
```

Lze definovat také indexované pole, známé jako tuple:

```php
$schema = Expect::array([
Expect::int(),
Expect::string(),
Expect::bool(),
]);

$processor->process($schema, [1, 'hello', true]); // OK
```


Zastaralé vlastnosti
--------------------
Expand Down
42 changes: 41 additions & 1 deletion schema/de/@home.texy
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Strukturen .[#toc-structures]

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

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

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

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

Das Array mit allen Struktureigenschaften wird von der Methode `getShape()` zurückgegeben.

Standardmäßig können keine zusätzlichen Elemente in den Eingabedaten enthalten sein:

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

Sie können eine neue Struktur erstellen, indem Sie mit `extend()` von einer anderen ableiten:

```php
$dog = Expect::structure([
'name' => Expect::string(),
'age' => Expect::int(),
]);

$dogWithBreed = $dog->extend([
'breed' => Expect::string(),
]);
```


Array .[#toc-array]
-------------------

Ein Array mit definierten Schlüsseln. Es gelten die gleichen Regeln wie für [Strukturen |#structure].

```php
$schema = Expect::array([
'required' => Expect::string()->required(),
'optional' => Expect::string(), // default value is null
]);
```

Sie können auch ein indiziertes Array, ein sogenanntes Tupel, definieren:

```php
$schema = Expect::array([
Expect::int(),
Expect::string(),
Expect::bool(),
]);

$processor->process($schema, [1, 'hello', true]); // OK
```


Verwerfungen .[#toc-deprecations]
---------------------------------
Expand Down
42 changes: 41 additions & 1 deletion schema/el/@home.texy
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault();

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

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

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

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

Ο πίνακας όλων των ιδιοτήτων της δομής επιστρέφεται από τη μέθοδο `getShape()`.

Από προεπιλογή, δεν μπορούν να υπάρχουν επιπλέον στοιχεία στα δεδομένα εισόδου:

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

Μπορείτε να δημιουργήσετε μια νέα δομή παράγοντας από μια άλλη χρησιμοποιώντας το `extend()`:

```php
$dog = Expect::structure([
'name' => Expect::string(),
'age' => Expect::int(),
]);

$dogWithBreed = $dog->extend([
'breed' => Expect::string(),
]);
```


Συστοιχία .[#toc-array]
-----------------------

Ένας πίνακας με καθορισμένα κλειδιά. Ισχύουν οι ίδιοι κανόνες όπως και για [τις δομές |#structure].

```php
$schema = Expect::array([
'required' => Expect::string()->required(),
'optional' => Expect::string(), // default value is null
]);
```

Μπορείτε επίσης να ορίσετε έναν δεικτοδοτούμενο πίνακα, γνωστό ως πλειάδα:

```php
$schema = Expect::array([
Expect::int(),
Expect::string(),
Expect::bool(),
]);

$processor->process($schema, [1, 'hello', true]); // OK
```


Αποσβέσεις .[#toc-deprecations]
-------------------------------
Expand Down
42 changes: 41 additions & 1 deletion schema/en/@home.texy
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Structures

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

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

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

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

The array of all structure properties is returned by the `getShape()` method.

By default, there can be no extra items in the input data:

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

You can create a new structure by deriving from another using `extend()`:

```php
$dog = Expect::structure([
'name' => Expect::string(),
'age' => Expect::int(),
]);

$dogWithBreed = $dog->extend([
'breed' => Expect::string(),
]);
```


Array .{data-version:1.3.2}
---------------------------

An array with defined keys. The same rules apply as for [structures|#structure].

```php
$schema = Expect::array([
'required' => Expect::string()->required(),
'optional' => Expect::string(), // default value is null
]);
```

You can also define an indexed array, known as a tuple:

```php
$schema = Expect::array([
Expect::int(),
Expect::string(),
Expect::bool(),
]);

$processor->process($schema, [1, 'hello', true]); // OK
```


Deprecations
------------
Expand Down
42 changes: 41 additions & 1 deletion schema/es/@home.texy
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Estructuras .[#toc-structures]

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

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

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

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

El array de todas las propiedades de la estructura es devuelto por el método `getShape()`.

Por defecto, no puede haber elementos adicionales en los datos de entrada:

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

Puede crear una nueva estructura derivando de otra mediante `extend()`:

```php
$dog = Expect::structure([
'name' => Expect::string(),
'age' => Expect::int(),
]);

$dogWithBreed = $dog->extend([
'breed' => Expect::string(),
]);
```


Matriz .[#toc-array]
--------------------

Un array con claves definidas. Se aplican las mismas reglas que para [las estructuras |#structure].

```php
$schema = Expect::array([
'required' => Expect::string()->required(),
'optional' => Expect::string(), // default value is null
]);
```

También puedes definir una matriz indexada, conocida como tupla:

```php
$schema = Expect::array([
Expect::int(),
Expect::string(),
Expect::bool(),
]);

$processor->process($schema, [1, 'hello', true]); // OK
```


Depreciaciones .[#toc-deprecations]
-----------------------------------
Expand Down
Loading

0 comments on commit a33ad75

Please sign in to comment.