Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs, translate brazilian portuguese #708

Merged
merged 13 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://github.com/yiisoft" target="_blank">
<img src="https://yiisoft.github.io/docs/images/yii_logo.svg" height="100px">
<img src="https://yiisoft.github.io/docs/images/yii_logo.svg" height="100px" alt="Yii">
</a>
<h1 align="center">Yii Validator</h1>
<br>
Expand Down Expand Up @@ -41,7 +41,7 @@ This package provides data validation capabilities.

## Installation

The package could be installed with composer:
The package could be installed with [Composer](https://getcomposer.org):

```shell
composer require yiisoft/validator
Expand Down Expand Up @@ -102,9 +102,12 @@ $result->getErrorMessages();

## Documentation

- [Guide](docs/guide/en/README.md)
luizcmarin marked this conversation as resolved.
Show resolved Hide resolved
- Guide: [English](docs/guide/en/README.md), [Português - Brasil](docs/guide/pt-BR/README.md)
- [Internals](docs/internals.md)

If you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.
You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).

## License

The Yii Validator is free software. It is released under the terms of the BSD License.
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/validator/issues?state=open",
"source": "https://github.com/yiisoft/validator",
"forum": "https://www.yiiframework.com/forum/",
"wiki": "https://www.yiiframework.com/wiki/",
"irc": "ircs://irc.libera.chat:6697/yii",
"chat": "https://t.me/yii3en",
"source": "https://github.com/yiisoft/validator"
"chat": "https://t.me/yii3en"
},
"funding": [
{
Expand Down Expand Up @@ -75,7 +75,7 @@
},
"config-plugin": {
"di": "di.php",
"params": "params.php"
"params": "params.php"
}
},
"config": {
Expand Down
10 changes: 3 additions & 7 deletions docs/guide/en/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Yii Validator

A package for validating data.

## Guides

### Validation
## Validation

- [Using validator](using-validator.md)
- [Result](result.md)
- [Conditional validation](conditional-validation.md)
- [Customizing error messages](customizing-error-messages.md)

### Rules
## Rules

- [Built-in rules](built-in-rules.md)
- [Callback](built-in-rules-callback.md)
Expand All @@ -23,7 +19,7 @@ A package for validating data.
- [Configuring rules via PHP attributes](configuring-rules-via-php-attributes.md)
- [Creating custom rules](creating-custom-rules.md)

### Miscellaneous
## Miscellaneous

- [Client-side validation](client-side-validation.md)
- [Extensions](extensions.md)
10 changes: 4 additions & 6 deletions docs/guide/en/built-in-rules-callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A condition can be within:
- Callable class.
- DTO (data transfer object) method.

The downside of using standalone functions and DTO methods is a lack of reusability. So they are mainly useful
The downside of using standalone functions and DTO methods is a lack of reusability. So they are mainly useful
for some specific non-repetitive conditions. Reusability can be achieved with callable classes, but depending on other
factors (the need for additional parameters for example), it might be a good idea to create a full-fledged
[custom rule](creating-custom-rules.md) with a separate handler instead.
Expand Down Expand Up @@ -54,7 +54,8 @@ new Callback(
### Value validation

`Callback` rule can be used to add validation missing in built-in rules for a single attribute's value. Below is the
example verifying that a value is a valid [YAML] string (additionally requires `yaml` PHP extension):
example verifying that a value is a valid [YAML](https://en.wikipedia.org/wiki/YAML) string
(additionally requires `yaml` PHP extension):

```php
use Exception;
Expand Down Expand Up @@ -85,7 +86,7 @@ new Callback(
```

> **Note:** Processing untrusted user input with `yaml_parse()` can be dangerous with certain settings. Please refer to
> [yaml_parse docs] for more details.
> [`yaml_parse()` docs](https://www.php.net/manual/en/function.yaml-parse.php) for more details.

### Usage of validation context for validating multiple attributes depending on each other

Expand Down Expand Up @@ -390,6 +391,3 @@ $rules = [
];
$result = (new Validator())->validate($data, $rules);
```

[YAML]: https://en.wikipedia.org/wiki/YAML
[yaml_parse docs]: https://www.php.net/manual/en/function.yaml-parse.php
9 changes: 3 additions & 6 deletions docs/guide/en/built-in-rules-composite.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `Composite` - grouping multiple validation rules

`Composite` allows to group multiple rules and configure the common [skipping options], such as `skipOnEmpty`,
`skipOnError` and `when`, for the whole set only once instead of repeating them in each rule:
`Composite` allows to group multiple rules and configure the common [skipping options](conditional-validation.md),
such as `skipOnEmpty`, `skipOnError` and `when`, for the whole set only once instead of repeating them in each rule:

```php
use Yiisoft\Validator\Rule\Composite;
Expand Down Expand Up @@ -47,7 +47,7 @@ use Yiisoft\Validator\Validator;
$result = (new Validator())->validate('John', new UsernameRuleSet());
```

It can also be combined with [Nested] rule to reuse rules for multiple attributes:
It can also be combined with [Nested](built-in-rules-nested.md) rule to reuse rules for multiple attributes:

```php
use Yiisoft\Validator\Rule\Composite;
Expand Down Expand Up @@ -82,6 +82,3 @@ final class ChartCoordinateRuleSet extends Composite
}
}
```

[skipping options]: conditional-validation.md
[Nested]: built-in-rules-nested.md
9 changes: 3 additions & 6 deletions docs/guide/en/built-in-rules-each.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `Each` - applying the same rules for each data item in the set

The `Each` rule allows the same rules to be applied to each data item in the set. The following example shows
the configuration for validating [RGB color] components:
the configuration for validating [RGB color](https://en.wikipedia.org/wiki/RGB_color_model) components:

```php
use Yiisoft\Validator\Rule\Each;
Expand Down Expand Up @@ -30,7 +30,7 @@ $rules = [
];
```

Validated data items are not limited to only "simple" values - `Each` can be used both within a `Nested` and contain
Validated data items are not limited to only "simple" values - `Each` can be used both within a `Nested` and contain
`Nested` rule covering one-to-many and many-to-many relations:

```php
Expand Down Expand Up @@ -59,7 +59,4 @@ $rule = new Nested([
]);
```

For more information about using it with `Nested`, see the [Nested] guide.

[RGB color]: https://en.wikipedia.org/wiki/RGB_color_model
[Nested]: built-in-rules-nested.md
For more information about using it with `Nested`, see the [Nested](built-in-rules-nested.md) guide.
9 changes: 5 additions & 4 deletions docs/guide/en/built-in-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Here is a list of all available built-in rules, divided by category.

### Type rules

- [BooleanType](../../../src/Rule/BooleanType.php)
- [FloatType](../../../src/Rule/FloatType.php)
- [IntegerType](../../../src/Rule/IntegerType.php)
- [StringType](../../../src/Rule/StringType.php)
- [BooleanType](../../../src/Rule/Type/BooleanType.php)
- [FloatType](../../../src/Rule/Type/FloatType.php)
- [IntegerType](../../../src/Rule/Type/IntegerType.php)
- [StringType](../../../src/Rule/Type/StringType.php)

### String rules

Expand Down Expand Up @@ -92,5 +92,6 @@ Some rules also have guides in addition to PHPDoc:

Can't find a rule? Feel free to submit an issue / PR, so it can be included in the package after review. Another option,
if your use case is less generic, is to search for [an extension] or [create a custom rule].

[an extension]: extensions.md
[create a custom rule]: creating-custom-rules.md
2 changes: 1 addition & 1 deletion docs/guide/en/configuring-rules-via-php-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class Truck extends Car
}
```

In this case the set of rules for `Truck` will be:
In this case the set of rules for `Truck` class will be:

```php
use Yiisoft\Validator\Rule\BooleanValue;
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/en/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use Yiisoft\Validator\ValidationContext;
use Yiisoft\Validator\Validator;

$context = new ValidationContext([On::SCENARIO_PARAMETER => 'signup']);
$result = (new Validator())->validate($userDto, context: $context));
$result = (new Validator())->validate($userDto, context: $context);
```

## Wrapper for Symfony rules
Expand Down
3 changes: 2 additions & 1 deletion docs/guide/en/result.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ Also keep in mind that attribute names must be strings, even when used with `Eac
$rule = new Each([new Number(min: 21)]),
```

With input containing non-string keys for top level attributes, for example, `[21, 22, 23, 20]`, InvalidArgumentException` will be thrown.
With input containing non-string keys for top level attributes, for example, `[21, 22, 23, 20]`,
`InvalidArgumentException` will be thrown.

Even array `['1' => 21, '2' => 22, '3' => 23, '4' => 20]` will cause an error, because PHP [will cast keys to the int type].

Expand Down
15 changes: 5 additions & 10 deletions docs/guide/pt-BR/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Validador Yii
# Yii Validator

Pacote para validação de dados.

## Guias

### Validação
## Validação

- [Usando o validador](using-validator.md)
- [Resultado](result.md)
- [Result](result.md)
- [Validação condicional](conditional-validation.md)
- [Personalizando mensagens de erro](customizing-error-messages.md)

### Regras
## Regras

- [Regras integradas](built-in-rules.md)
- [Callback](built-in-rules-callback.md)
Expand All @@ -23,8 +19,7 @@ Pacote para validação de dados.
- [Configurando regras via atributos PHP](configuring-rules-via-php-attributes.md)
- [Criando regras personalizadas](creating-custom-rules.md)


### Diversos
## Diversos

- [Validação do lado do cliente](client-side-validation.md)
- [Extensões](extensions.md)
30 changes: 18 additions & 12 deletions docs/guide/pt-BR/built-in-rules-callback.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# `Callback` - um wrapper em torno de `callable`
# `Callback` - um wrapper em torno de [`callables`]

Esta regra permite a validação do valor do atributo atual (mas não limitado a ele) com uma condição arbitrária dentro de um
callable. A vantagem é que não há necessidade de criar uma regra e um manipulador personalizado separados.

Uma condição pode estar dentro de:

- Função callable autônoma.
- Classe Callable.
- Método DTO (objeto de transferência de dados).
- Função [`callables`] autônoma.
- Classe `Callable`.
- Método [`DTO`] (objeto de transferência de dados).

A desvantagem de usar funções independentes e métodos DTO é a falta da capacidade de reutilização. Então eles são principalmente úteis
A desvantagem de usar funções independentes e métodos [`DTO`] é a falta da capacidade de reutilização. Então eles são principalmente úteis
para algumas condições específicas não repetitivas. A reutilização pode ser alcançada com classes que podem ser chamadas, mas dependendo de outros
fatores (a necessidade de parâmetros adicionais, por exemplo), pode ser uma boa ideia criar um relatório completo
[regra personalizada](creating-custom-rules.md) com um manipulador separado.
[regra personalizada] com um manipulador separado.

A sintaxe da função de retorno de chamada é a seguinte:

Expand Down Expand Up @@ -54,7 +54,7 @@ new Callback(
### Validação de valor

A regra `Callback` pode ser usada para adicionar validação ausente nas regras integradas para o valor de um único atributo. Abaixo está o
exemplo verificando se um valor é uma string [YAML] válida (requer adicionalmente a extensão PHP `yaml`):
exemplo verificando se um valor é uma string [YAML] válida (requer adicionalmente a extensão [PHP `yaml`]):

```php
use Exception;
Expand Down Expand Up @@ -84,8 +84,8 @@ new Callback(
);
```

> **Nota:** Processar entradas de usuários não confiáveis com `yaml_parse()` pode ser perigoso com certas configurações. Consulte
> a documentação [yaml_parse] para mais detalhes.
> **Nota:** Processar entradas de usuários não confiáveis com [`yaml_parse()`] pode ser perigoso com certas configurações. Consulte
> a documentação [`yaml_parse()`] para mais detalhes.

### Uso do contexto de validação para validar vários atributos dependendo uns dos outros

Expand Down Expand Up @@ -134,7 +134,7 @@ $rules = [
];
```

### Substituindo o código padrão por regras separadas e `when`
### Substituindo o código padrão por regras separadas e [`when`]

No entanto, alguns casos de uso de contexto de validação podem levar a um código padrão:

Expand Down Expand Up @@ -229,7 +229,7 @@ final class Config {
A sintaxe é a mesma de uma função normal. Observe que não há restrições nos níveis de visibilidade e modificadores estáticos,
todos eles podem ser usados (`public`, `protected`, `private`, `static`).

Usar um argumento `callback` em vez de `method` com atributos PHP é proibido devido à restrições da linguagem PHP atual
Usar um argumento `callback` em vez de um [`método`] com atributos PHP é proibido devido à restrições da linguagem PHP atual
(um retorno de chamada não pode estar dentro de um atributo PHP).

### Para todo o objeto
Expand Down Expand Up @@ -391,5 +391,11 @@ $rules = [
$result = (new Validator())->validate($data, $rules);
```

[`callables`]: https://www.php.net/manual/pt_BR/language.types.callable.php
[regra personalizada]: creating-custom-rules.md
[YAML]: https://en.wikipedia.org/wiki/YAML
[yaml_parse]: https://www.php.net/manual/en/function.yaml-parse.php
[PHP `yaml`]: https://www.php.net/manual/pt_BR/book.yaml.php
[`yaml_parse()`]: https://www.php.net/manual/pt_BR/function.yaml-parse.php
[`DTO`]: https://pt.wikipedia.org/wiki/Data_transfer_object
[`when`]: conditional-validation.md#when
[`método`]: built-in-rules-callback.md#para-propriedades
4 changes: 2 additions & 2 deletions docs/guide/pt-BR/built-in-rules-compare.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `Compare` - comparando o valor validado com o valor alvo

## Usando com objetos `DateTime`
## Usando com objetos [`DateTime`]

### Uso básico

Expand Down Expand Up @@ -37,4 +37,4 @@ $rules = [
),
],
];
```
```
16 changes: 10 additions & 6 deletions docs/guide/pt-BR/built-in-rules-composite.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `Composite` - agrupando múltiplas regras de validação

`Composite` permite agrupar múltiplas regras e configurar as [opções de salto] comuns, como `skipOnEmpty`,
`skipOnError` e `when`, para todo o conjunto apenas uma vez em vez de repeti-los em cada regra:
`Composite` permite agrupar múltiplas regras e configurar as [opções de salto] comuns, como [`skipOnEmpty`],
[`skipOnError`] e [`when`], para todo o conjunto apenas uma vez ao invés de repeti-los em cada regra:

```php
use Yiisoft\Validator\Rule\Composite;
Expand All @@ -19,8 +19,8 @@ new Composite(

## Reutilizando múltiplas regras/regra única com as mesmas opções

`Composite` é uma das poucas regras integradas que não é `final`. Isso significa que você pode estendê-lo e substituir o
Método `getRules()` para criar um conjunto reutilizável de regras:
`Composite` é uma das poucas regras integradas que não é [`final`]. Isso significa que você pode estendê-lo e substituir o
método `getRules()` para criar um conjunto reutilizável de regras:

```php
use Yiisoft\Validator\Rule\Composite;
Expand All @@ -47,7 +47,7 @@ use Yiisoft\Validator\Validator;
$result = (new Validator())->validate('John', new UsernameRuleSet());
```

Também pode ser combinado com a regra [Nested] para reutilizar regras para vários atributos:
Também pode ser combinado com a regra [`Nested`] para reutilizar regras para vários atributos:

```php
use Yiisoft\Validator\Rule\Composite;
Expand Down Expand Up @@ -84,4 +84,8 @@ final class ChartCoordinateRuleSet extends Composite
```

[opções de salto]: conditional-validation.md
[Nested]: built-in-rules-nested.md
[`Nested`]: built-in-rules-nested.md
[`when`]: conditional-validation.md#when
[`final`]: https://www.php.net/manual/pt_BR/language.oop5.final.php
[`skipOnEmpty`]: conditional-validation.md#skiponempty---ignorando-uma-regra-se-o-valor-validado-estiver-vazio
[`skipOnError`]: conditional-validation.md#skipOnError---pula-uma-regra-no-conjunto-se-a-anterior-falhou
Loading
Loading