From a33ad759ef9b31458aa0e01ae3d7c644abcbb464 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 5 Oct 2024 18:19:37 +0200 Subject: [PATCH] nette/schema 1.3.2 --- schema/bg/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/cs/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/de/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/el/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/en/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/es/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/fr/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/hu/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/it/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/ja/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/pl/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/pt/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/ro/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/ru/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/sl/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/tr/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- schema/uk/@home.texy | 42 +++++++++++++++++++++++++++++++++++++++++- 17 files changed, 697 insertions(+), 17 deletions(-) diff --git a/schema/bg/@home.texy b/schema/bg/@home.texy index 06400a7c5b..a86efec30c 100644 --- a/schema/bg/@home.texy +++ b/schema/bg/@home.texy @@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault(); Структурите са обекти с определени ключове. Всяка от тези двойки ключ => стойност се нарича "свойство": -Структурите приемат масиви и обекти и връщат обекти `stdClass` (освен ако не ги промените с `castTo('array')` и т.н.). +Структурите приемат масиви и обекти и връщат обекти `stdClass`. По подразбиране всички свойства са незадължителни и имат стойност по подразбиране `null`. Можете да дефинирате задължителни свойства, като използвате `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // ОК, връща {'optional' => null, 'nullable' => null} ``` +Масивът от всички свойства на структурата се връща от метода `getShape()`. + По подразбиране във входните данни не може да има допълнителни елементи: ```php @@ -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] --------------------------------------------- diff --git a/schema/cs/@home.texy b/schema/cs/@home.texy index b2d8b4b01f..5adb759b64 100644 --- a/schema/cs/@home.texy +++ b/schema/cs/@home.texy @@ -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()`: @@ -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 @@ -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 -------------------- diff --git a/schema/de/@home.texy b/schema/de/@home.texy index e9493a67c2..19bc03279b 100644 --- a/schema/de/@home.texy +++ b/schema/de/@home.texy @@ -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: @@ -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 @@ -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] --------------------------------- diff --git a/schema/el/@home.texy b/schema/el/@home.texy index 73d579437b..d8e72302de 100644 --- a/schema/el/@home.texy +++ b/schema/el/@home.texy @@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault(); Οι δομές είναι αντικείμενα με καθορισμένα κλειδιά. Κάθε ένα από αυτά τα ζεύγη κλειδί => τιμή αναφέρεται ως "ιδιότητα": -Οι δομές δέχονται πίνακες και αντικείμενα και επιστρέφουν αντικείμενα `stdClass` (εκτός αν το αλλάξετε με το `castTo('array')`, κ.λπ.). +Οι δομές δέχονται πίνακες και αντικείμενα και επιστρέφουν αντικείμενα `stdClass`. Από προεπιλογή, όλες οι ιδιότητες είναι προαιρετικές και έχουν προεπιλεγμένη τιμή `null`. Μπορείτε να ορίσετε υποχρεωτικές ιδιότητες χρησιμοποιώντας το `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, επιστρέφει {'optional' => null, 'nullable' => null} ``` +Ο πίνακας όλων των ιδιοτήτων της δομής επιστρέφεται από τη μέθοδο `getShape()`. + Από προεπιλογή, δεν μπορούν να υπάρχουν επιπλέον στοιχεία στα δεδομένα εισόδου: ```php @@ -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] ------------------------------- diff --git a/schema/en/@home.texy b/schema/en/@home.texy index e9da6d083a..5a47157acd 100644 --- a/schema/en/@home.texy +++ b/schema/en/@home.texy @@ -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()`: @@ -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 @@ -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 ------------ diff --git a/schema/es/@home.texy b/schema/es/@home.texy index 5610a275b7..4334202fcc 100644 --- a/schema/es/@home.texy +++ b/schema/es/@home.texy @@ -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()`: @@ -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 @@ -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] ----------------------------------- diff --git a/schema/fr/@home.texy b/schema/fr/@home.texy index 036493c90a..0019032c5e 100644 --- a/schema/fr/@home.texy +++ b/schema/fr/@home.texy @@ -197,7 +197,7 @@ Structures .[#toc-structures] Les structures sont des objets avec des clés définies. Chacune de ces paires clé => valeur est appelée "propriété" : -Les structures acceptent des tableaux et des objets et renvoient des objets `stdClass` (sauf si vous le changez avec `castTo('array')`, etc.). +Les structures acceptent des tableaux et des objets et renvoient des objets `stdClass`. Par défaut, toutes les propriétés sont facultatives et ont une valeur par défaut de `null`. Vous pouvez définir des propriétés obligatoires en utilisant `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, retourne {'optional' => null, 'nullable' => null}. ``` +Le tableau de toutes les propriétés de la structure est renvoyé par la méthode `getShape()`. + Par défaut, il ne peut y avoir aucun élément supplémentaire dans les données d'entrée : ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK $processor->process($schema, ['additional' => true]); // ERREUR ``` +Vous pouvez créer une nouvelle structure en dérivant d'une autre à l'aide de `extend()`: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Tableau .[#toc-array] +--------------------- + +Un tableau dont les clés sont définies. Les mêmes règles que pour les [structures |#structure] s'appliquent. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +Vous pouvez également définir un tableau indexé, appelé tuple : + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Dépréciations .[#toc-deprecations] ---------------------------------- diff --git a/schema/hu/@home.texy b/schema/hu/@home.texy index c98bb38845..1c9423063c 100644 --- a/schema/hu/@home.texy +++ b/schema/hu/@home.texy @@ -197,7 +197,7 @@ Struktúrák .[#toc-structures] A struktúrák meghatározott kulcsokkal rendelkező objektumok. A kulcs => érték párok mindegyikét "tulajdonságnak" nevezzük: -A struktúrák tömböket és objektumokat fogadnak el, és objektumokat adnak vissza `stdClass` (hacsak nem változtatjuk meg a `castTo('array')`, stb. segítségével). +A struktúrák tömböket és objektumokat fogadnak, és objektumokat adnak vissza `stdClass`. Alapértelmezés szerint minden tulajdonság opcionális, és alapértelmezett értéke `null`. Kötelező tulajdonságokat a `required()` segítségével lehet definiálni: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, visszatér {'optional' => null, 'nullable' => null} ``` +A `getShape()` módszer a struktúra összes tulajdonságát tartalmazó tömböt adja vissza. + Alapértelmezés szerint a bemeneti adatokban nem lehetnek extra elemek: ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK $processor->process($schema, ['additional' => true]); // HIBA ``` +Új struktúrát hozhat létre egy másik struktúrából származtatva a `extend()` segítségével: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Array .[#toc-array] +------------------- + +Meghatározott kulcsokkal rendelkező tömb. Ugyanazok a szabályok vonatkoznak rá, mint a [struktúrákra |#structure]. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +Definiálhatunk indexelt tömböt is, amelyet tuple-nek nevezünk: + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Deprecations .[#toc-deprecations] --------------------------------- diff --git a/schema/it/@home.texy b/schema/it/@home.texy index 01c04d05c8..3b1faef1c6 100644 --- a/schema/it/@home.texy +++ b/schema/it/@home.texy @@ -197,7 +197,7 @@ Strutture .[#toc-structures] Le strutture sono oggetti con chiavi definite. Ciascuna di queste coppie chiave => valore viene definita "proprietà": -Le strutture accettano array e oggetti e restituiscono oggetti `stdClass` (a meno che non si cambi con `castTo('array')`, ecc.). +Le strutture accettano array e oggetti e restituiscono oggetti `stdClass`. Per impostazione predefinita, tutte le proprietà sono opzionali e hanno un valore predefinito di `null`. È possibile definire proprietà obbligatorie utilizzando `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, restituisce {'optional' => null, 'nullable' => null} ``` +L'array di tutte le proprietà della struttura viene restituito dal metodo `getShape()`. + Per impostazione predefinita, non ci possono essere elementi extra nei dati di input: ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK $processor->process($schema, ['additional' => true]); // ERRORE ``` +È possibile creare una nuova struttura derivandola da un'altra utilizzando `extend()`: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Schieramento .[#toc-array] +-------------------------- + +Un array con chiavi definite. Si applicano le stesse regole delle [strutture |#structure]. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +È anche possibile definire un array indicizzato, noto come tupla: + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Deprecazioni .[#toc-deprecations] --------------------------------- diff --git a/schema/ja/@home.texy b/schema/ja/@home.texy index a29b9a1617..fba7d1b25e 100644 --- a/schema/ja/@home.texy +++ b/schema/ja/@home.texy @@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault(); 構造体は、定義されたキーを持つオブジェクトである。このキー => 値のペアをそれぞれ「プロパティ」と呼びます。 -構造体は配列やオブジェクトを受け入れ、オブジェクトを返す`stdClass` (`castTo('array')`, などで変更しない限り)。 +構造体は配列やオブジェクトを受け入れ、オブジェクトを返す`stdClass` 。 デフォルトでは、すべてのプロパティはオプションであり、デフォルト値は`null` です。必須プロパティは`required()` を使って定義できます。 @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, returns {'optional' => null, 'nullable' => null} ``` +すべての構造体プロパティの配列は、`getShape()` メソッドによって返される。 + デフォルトでは、入力データに余分な項目は存在できない。 ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK $processor->process($schema, ['additional' => true]); // ERROR ``` +`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] -------------------------- diff --git a/schema/pl/@home.texy b/schema/pl/@home.texy index c05548476b..28adaf5933 100644 --- a/schema/pl/@home.texy +++ b/schema/pl/@home.texy @@ -197,7 +197,7 @@ Struktury .[#toc-structures] Struktury to obiekty o zdefiniowanych kluczach. Każda z par klucz => wartość jest określana jako "właściwość": -Struktury przyjmują tablice i obiekty i zwracają `stdClass` obiekty (chyba że zmienisz to za pomocą `castTo('array')` itp.). +Struktury akceptują tablice i obiekty oraz zwracają obiekty `stdClass`. Domyślnie wszystkie właściwości są opcjonalne i domyślnie ustawione na `null`. Możesz zdefiniować właściwości obowiązkowe używając `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, vrací {'optional' => null, 'nullable' => null} ``` +Tablica wszystkich właściwości struktury jest zwracana przez metodę `getShape()`. + Domyślnie w danych wejściowych nie może być żadnych dodatkowych elementów: ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK $processor->process($schema, ['additional' => true]); // CHYBA ``` +Nową strukturę można utworzyć poprzez wyprowadzenie jej z innej za pomocą `extend()`: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Tablica .[#toc-array] +--------------------- + +Tablica ze zdefiniowanymi kluczami. Obowiązują te same zasady, co w przypadku [struktur |#structure]. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +Można również zdefiniować tablicę indeksowaną, znaną jako krotka: + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Właściwości przestarzałe .[#toc-deprecations] --------------------------------------------- diff --git a/schema/pt/@home.texy b/schema/pt/@home.texy index 76b78e5a6e..71c816a2bb 100644 --- a/schema/pt/@home.texy +++ b/schema/pt/@home.texy @@ -197,7 +197,7 @@ Estruturas .[#toc-structures] As estruturas são objetos com chaves definidas. Cada uma destas chaves => pares de valores é chamada de "propriedade": -As estruturas aceitam matrizes e objetos e retornam objetos `stdClass` (a menos que você altere com `castTo('array')`, etc.). +As estruturas aceitam matrizes e objetos e retornam objetos `stdClass`. Por padrão, todas as propriedades são opcionais e têm um valor padrão de `null`. Você pode definir propriedades obrigatórias usando `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, retorna {'opcional' => nulo, 'anulável' => nulo} ``` +A matriz de todas as propriedades da estrutura é retornada pelo método `getShape()`. + Por padrão, não pode haver itens extras nos dados de entrada: ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK $processor->process($schema, ['additional' => true]); // ERROR ``` +Você pode criar uma nova estrutura derivando de outra usando `extend()`: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Matriz .[#toc-array] +-------------------- + +Uma matriz com chaves definidas. Aplicam-se as mesmas regras das [estruturas |#structure]. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +Você também pode definir uma matriz indexada, conhecida como tupla: + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Depreciações .[#toc-deprecations] --------------------------------- diff --git a/schema/ro/@home.texy b/schema/ro/@home.texy index 16cb3060f3..2e0b9582ad 100644 --- a/schema/ro/@home.texy +++ b/schema/ro/@home.texy @@ -197,7 +197,7 @@ Structuri .[#toc-structures] Structurile sunt obiecte cu chei definite. Fiecare dintre aceste perechi cheie => valoare este denumită "proprietate": -Structurile acceptă matrici și obiecte și returnează obiecte `stdClass` (dacă nu se modifică cu `castTo('array')`, etc.). +Structurile acceptă matrici și obiecte și returnează obiecte `stdClass`. În mod implicit, toate proprietățile sunt opționale și au o valoare implicită de `null`. Puteți defini proprietățile obligatorii utilizând `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, returnează {'optional' => null, 'nullable' => null} ``` +Matricea tuturor proprietăților structurii este returnată de metoda `getShape()`. + În mod implicit, nu pot exista elemente suplimentare în datele de intrare: ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // OK $processor->process($schema, ['additional' => true]); // ERROR ``` +Puteți crea o structură nouă derivând din alta folosind `extend()`: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Array .[#toc-array] +------------------- + +Un array cu chei definite. Se aplică aceleași reguli ca pentru [structuri |#structure]. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +De asemenea, puteți defini un array indexat, cunoscut sub numele de tuple: + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Deprecieri .[#toc-deprecations] ------------------------------- diff --git a/schema/ru/@home.texy b/schema/ru/@home.texy index e01893dc5a..7f87c34c55 100644 --- a/schema/ru/@home.texy +++ b/schema/ru/@home.texy @@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault(); Структуры — это объекты с определенными ключами. Каждая из этих пар ключ => значение называется "свойством": -Структуры принимают массивы и объекты и возвращают объекты `stdClass` (если вы не измените его с помощью `castTo('array')` и т. д.). +Структуры принимают массивы и объекты и возвращают объекты `stdClass`. По умолчанию все свойства являются необязательными и имеют значение по умолчанию `null`. Вы можете определить обязательные свойства, используя `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, возвращает {'optional' => null, 'nullable' => null} ``` +Массив всех свойств структуры возвращается методом `getShape()`. + По умолчанию, во входных данных не может быть лишних элементов: ```php @@ -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 +``` + Устаревшие элементы ------------------- diff --git a/schema/sl/@home.texy b/schema/sl/@home.texy index c8c5e6eea5..0c432ad504 100644 --- a/schema/sl/@home.texy +++ b/schema/sl/@home.texy @@ -197,7 +197,7 @@ Strukture .[#toc-structures] Strukture so predmeti z določenimi ključi. Vsak od teh parov ključ => vrednost se imenuje "lastnost": -Strukture sprejemajo polja in predmete ter vračajo predmete `stdClass` (razen če jih spremenite s `castTo('array')`, itd.). +Strukture sprejemajo polja in predmete ter vračajo predmete `stdClass`. Privzeto so vse lastnosti neobvezne in imajo privzeto vrednost `null`. Obvezne lastnosti lahko določite z uporabo `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // V redu, vrne {'optional' => null, 'nullable' => null} ``` +Metoda `getShape()` vrne polje vseh lastnosti strukture. + Privzeto je, da v vhodnih podatkih ne sme biti nobenih dodatnih elementov: ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // V REDU $processor->process($schema, ['additional' => true]); // ERROR ``` +Novo strukturo lahko ustvarite tako, da jo izpeljete iz druge strukture z uporabo `extend()`: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Polje .[#toc-array] +------------------- + +Polje z določenimi ključi. Veljajo enaka pravila kot za [strukture |#structure]. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +Opredelite lahko tudi indeksirano polje, znano kot tuple: + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Deprecations .[#toc-deprecations] --------------------------------- diff --git a/schema/tr/@home.texy b/schema/tr/@home.texy index a2be4b7dbb..47ba016283 100644 --- a/schema/tr/@home.texy +++ b/schema/tr/@home.texy @@ -197,7 +197,7 @@ Yapılar .[#toc-structures] Yapılar, tanımlanmış anahtarları olan nesnelerdir. Bu anahtar => değer çiftlerinin her biri "özellik" olarak adlandırılır: -Yapılar dizileri ve nesneleri kabul eder ve `stdClass` nesnelerini döndürür ( `castTo('array')`, vb. ile değiştirmediğiniz sürece). +Yapılar dizileri ve nesneleri kabul eder ve nesneleri döndürür `stdClass`. Varsayılan olarak, tüm özellikler isteğe bağlıdır ve varsayılan değerleri `null` şeklindedir. `required()` adresini kullanarak zorunlu özellikleri tanımlayabilirsiniz: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // Tamam, {'optional' => null, 'nullable' => null} döndürür ``` +Tüm yapı özelliklerinin dizisi `getShape()` yöntemi tarafından döndürülür. + Varsayılan olarak, giriş verilerinde fazladan öğe bulunamaz: ```php @@ -263,6 +265,44 @@ $processor->process($schema, ['additional' => 1]); // Tamam $processor->process($schema, ['additional' => true]); // ERROR ``` +`extend()` adresini kullanarak başka bir yapıdan türeterek yeni bir yapı oluşturabilirsiniz: + +```php +$dog = Expect::structure([ + 'name' => Expect::string(), + 'age' => Expect::int(), +]); + +$dogWithBreed = $dog->extend([ + 'breed' => Expect::string(), +]); +``` + + +Dizi .[#toc-array] +------------------ + +Tanımlanmış anahtarları olan bir dizi. [Yapılar |#structure] için geçerli olan kuralların aynısı geçerlidir. + +```php +$schema = Expect::array([ + 'required' => Expect::string()->required(), + 'optional' => Expect::string(), // default value is null +]); +``` + +Ayrıca tuple olarak bilinen indeksli bir dizi de tanımlayabilirsiniz: + +```php +$schema = Expect::array([ + Expect::int(), + Expect::string(), + Expect::bool(), +]); + +$processor->process($schema, [1, 'hello', true]); // OK +``` + Kullanımdan kaldırmalar .[#toc-deprecations] -------------------------------------------- diff --git a/schema/uk/@home.texy b/schema/uk/@home.texy index 44e37d9b68..fa6b9d5b4c 100644 --- a/schema/uk/@home.texy +++ b/schema/uk/@home.texy @@ -197,7 +197,7 @@ Expect::anyOf(Expect::string('hello'), true, null)->firstIsDefault(); Структури - це об'єкти з певними ключами. Кожна з цих пар ключ => значення називається "властивістю": -Структури приймають масиви та об'єкти і повертають об'єкти `stdClass` (якщо ви не зміните його за допомогою `castTo('array')` тощо). +Структури приймають масиви та об'єкти і повертають об'єкти `stdClass`. За замовчуванням усі властивості є необов'язковими і мають значення за замовчуванням `null`. Ви можете визначити обов'язкові властивості, використовуючи `required()`: @@ -241,6 +241,8 @@ $processor->process($schema, ['nullable' => null]); // OK, повертає {'optional' => null, 'nullable' => null} ``` +Масив усіх властивостей структури повертається методом `getShape()`. + За замовчуванням, у вхідних даних не може бути зайвих елементів: ```php @@ -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] ----------------------------------------------