django-rule-engine 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_rule_engine-1.0.0/INDEX.md +253 -0
- django_rule_engine-1.0.0/INSTALL.md +206 -0
- django_rule_engine-1.0.0/LICENSE +28 -0
- django_rule_engine-1.0.0/MANIFEST.in +8 -0
- django_rule_engine-1.0.0/MIGRATION_GUIDE.md +484 -0
- django_rule_engine-1.0.0/PKG-INFO +122 -0
- django_rule_engine-1.0.0/QUICKSTART.md +194 -0
- django_rule_engine-1.0.0/README.md +74 -0
- django_rule_engine-1.0.0/pyproject.toml +106 -0
- django_rule_engine-1.0.0/setup.cfg +4 -0
- django_rule_engine-1.0.0/setup.py +41 -0
- django_rule_engine-1.0.0/src/django_rule_engine/__init__.py +5 -0
- django_rule_engine-1.0.0/src/django_rule_engine/api/__init__.py +5 -0
- django_rule_engine-1.0.0/src/django_rule_engine/api/urls.py +8 -0
- django_rule_engine-1.0.0/src/django_rule_engine/api/views.py +85 -0
- django_rule_engine-1.0.0/src/django_rule_engine/apps.py +11 -0
- django_rule_engine-1.0.0/src/django_rule_engine/fields/__init__.py +6 -0
- django_rule_engine-1.0.0/src/django_rule_engine/fields/rule_field.py +89 -0
- django_rule_engine-1.0.0/src/django_rule_engine/fields/rule_widget.py +85 -0
- django_rule_engine-1.0.0/src/django_rule_engine/fields/test_rule_field.py +297 -0
- django_rule_engine-1.0.0/src/django_rule_engine/static/rule_widget/codemirror-rule-engine.js +156 -0
- django_rule_engine-1.0.0/src/django_rule_engine/static/rule_widget/rule_widget.css +236 -0
- django_rule_engine-1.0.0/src/django_rule_engine/static/rule_widget/rule_widget.js +246 -0
- django_rule_engine-1.0.0/src/django_rule_engine/static/rule_widget/rule_widget_highlighting.css +54 -0
- django_rule_engine-1.0.0/src/django_rule_engine/templates/widgets/rule_widget.html +48 -0
- django_rule_engine-1.0.0/src/django_rule_engine.egg-info/PKG-INFO +122 -0
- django_rule_engine-1.0.0/src/django_rule_engine.egg-info/SOURCES.txt +28 -0
- django_rule_engine-1.0.0/src/django_rule_engine.egg-info/dependency_links.txt +1 -0
- django_rule_engine-1.0.0/src/django_rule_engine.egg-info/requires.txt +10 -0
- django_rule_engine-1.0.0/src/django_rule_engine.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# 📚 RuleField - Índice da Documentação
|
|
2
|
+
|
|
3
|
+
> Campo Django customizado para rule-engine com editor visual e validação dinâmica
|
|
4
|
+
|
|
5
|
+
## 🎯 Documentos Disponíveis
|
|
6
|
+
|
|
7
|
+
### Para Começar
|
|
8
|
+
|
|
9
|
+
1. **[INSTALL.md](./INSTALL.md)** - 📦 Instalação e Setup Inicial
|
|
10
|
+
- O que foi criado
|
|
11
|
+
- Como usar
|
|
12
|
+
- Funcionalidades
|
|
13
|
+
- Exemplo implementado
|
|
14
|
+
- Testes
|
|
15
|
+
- Próximos passos
|
|
16
|
+
|
|
17
|
+
2. **[QUICKSTART.md](./QUICKSTART.md)** - ⚡ Guia Rápido (5 minutos)
|
|
18
|
+
- Instalação rápida em 4 passos
|
|
19
|
+
- Sintaxe básica
|
|
20
|
+
- Exemplos práticos
|
|
21
|
+
- Troubleshooting
|
|
22
|
+
- FAQ
|
|
23
|
+
|
|
24
|
+
### Documentação Completa
|
|
25
|
+
|
|
26
|
+
3. **[README.md](./README.md)** - 📖 Documentação Completa (450+ linhas)
|
|
27
|
+
- Características detalhadas
|
|
28
|
+
- Instalação
|
|
29
|
+
- Uso básico e avançado
|
|
30
|
+
- Sintaxe completa de regras
|
|
31
|
+
- Usando no Django Admin
|
|
32
|
+
- Validação programática
|
|
33
|
+
- API de validação
|
|
34
|
+
- Customização
|
|
35
|
+
- Exemplo completo
|
|
36
|
+
- Exemplos de regras por caso de uso
|
|
37
|
+
- Troubleshooting
|
|
38
|
+
- Referências
|
|
39
|
+
|
|
40
|
+
### Guias Especializados
|
|
41
|
+
|
|
42
|
+
4. **[MIGRATION_GUIDE.md](./MIGRATION_GUIDE.md)** - 🔄 Guia de Migração
|
|
43
|
+
- Migrar TextField existente
|
|
44
|
+
- Aplicar em outro projeto
|
|
45
|
+
- Customizar para necessidades específicas
|
|
46
|
+
- Rollback/Reversão
|
|
47
|
+
- Troubleshooting de migração
|
|
48
|
+
- Checklist completo
|
|
49
|
+
|
|
50
|
+
### Código e Exemplos
|
|
51
|
+
|
|
52
|
+
5. **[examples.py](./EXAMPLES.md)** - 💻 Exemplos de Código (350+ linhas)
|
|
53
|
+
- Exemplo 1: Uso básico
|
|
54
|
+
- Exemplo 2: Com dados de exemplo
|
|
55
|
+
- Exemplo 3: Validação de usuário
|
|
56
|
+
- Exemplo 4: Regra de desconto
|
|
57
|
+
- Exemplo 5: Múltiplas regras
|
|
58
|
+
- Lista de regras comuns
|
|
59
|
+
|
|
60
|
+
7. **[VISUAL_DEMO.py](./VISUAL_DEMO.md)** - 🎨 Demonstração Visual
|
|
61
|
+
- Definição no modelo
|
|
62
|
+
- Aparência no admin
|
|
63
|
+
- Fluxo de uso
|
|
64
|
+
- Exemplos de validação
|
|
65
|
+
- Cores e temas
|
|
66
|
+
- Atalhos de teclado
|
|
67
|
+
- Responsividade
|
|
68
|
+
- Animações
|
|
69
|
+
- Acessibilidade
|
|
70
|
+
- Compatibilidade
|
|
71
|
+
|
|
72
|
+
### Scripts Utilitários
|
|
73
|
+
|
|
74
|
+
8. **[setup.sh](./setup.sh)** - 🔧 Script de Setup Automatizado
|
|
75
|
+
- Verifica dependências
|
|
76
|
+
- Cria migrations
|
|
77
|
+
- Aplica migrations
|
|
78
|
+
- Coleta arquivos estáticos
|
|
79
|
+
- Executa testes
|
|
80
|
+
|
|
81
|
+
### Arquivos de Código
|
|
82
|
+
|
|
83
|
+
9. **[rule_field.py](./rule_field.py)** - Campo Django customizado
|
|
84
|
+
10. **[rule_widget.py](./rule_widget.py)** - Widget para o admin
|
|
85
|
+
11. **[../templates/widgets/rule_widget.html](../templates/widgets/rule_widget.html)** - Template HTML
|
|
86
|
+
12. **[../static/rule_widget/rule_widget.js](../static/rule_widget/rule_widget.js)** - JavaScript
|
|
87
|
+
13. **[../static/rule_widget/rule_widget.css](../static/rule_widget/rule_widget.css)** - CSS
|
|
88
|
+
14. **[../api/views.py](../api/views.py)** - API endpoint
|
|
89
|
+
15. **[../api/urls.py](../api/urls.py)** - URLs da API
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🚀 Por Onde Começar?
|
|
94
|
+
|
|
95
|
+
### Sou Novo no RuleField
|
|
96
|
+
1. Leia: **[INSTALL.md](./INSTALL.md)** (3 min)
|
|
97
|
+
2. Leia: **[QUICKSTART.md](./QUICKSTART.md)** (5 min)
|
|
98
|
+
3. Execute: `bash setup.sh`
|
|
99
|
+
4. Teste no admin!
|
|
100
|
+
|
|
101
|
+
### Quero Usar no Meu Projeto
|
|
102
|
+
1. Leia: **[README.md](./README.md)** seção "Uso Básico"
|
|
103
|
+
2. Copie os arquivos necessários
|
|
104
|
+
3. Siga: **[MIGRATION_GUIDE.md](./MIGRATION_GUIDE.md)** seção 2
|
|
105
|
+
|
|
106
|
+
### Preciso Customizar
|
|
107
|
+
1. Leia: **[README.md](./README.md)** seção "Customização"
|
|
108
|
+
2. Veja: **[examples.py](./examples.py)** para inspiração
|
|
109
|
+
3. Consulte: **[MIGRATION_GUIDE.md](./MIGRATION_GUIDE.md)** seção 3
|
|
110
|
+
|
|
111
|
+
### Quero Ver Como Funciona
|
|
112
|
+
1. Abra: **[VISUAL_DEMO.py](./VISUAL_DEMO.py)**
|
|
113
|
+
2. Veja: **[examples.py](./examples.py)**
|
|
114
|
+
3. Execute: `python manage.py shell < test_rule_field.py`
|
|
115
|
+
|
|
116
|
+
### Tenho um Problema
|
|
117
|
+
1. Consulte: **[QUICKSTART.md](./QUICKSTART.md)** seção "Troubleshooting"
|
|
118
|
+
2. Veja: **[README.md](./README.md)** seção "Troubleshooting"
|
|
119
|
+
3. Confira: **[MIGRATION_GUIDE.md](./MIGRATION_GUIDE.md)** seção "Troubleshooting"
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 📊 Resumo por Tipo de Documento
|
|
124
|
+
|
|
125
|
+
### 📘 Documentação Geral
|
|
126
|
+
- INSTALL.md - Instalação inicial
|
|
127
|
+
- README.md - Documentação completa
|
|
128
|
+
- QUICKSTART.md - Início rápido
|
|
129
|
+
|
|
130
|
+
### 🔧 Guias Técnicos
|
|
131
|
+
- MIGRATION_GUIDE.md - Migração e customização
|
|
132
|
+
|
|
133
|
+
### 💻 Código e Exemplos
|
|
134
|
+
- examples.py - 5 exemplos completos
|
|
135
|
+
- test_rule_field.py - Suite de testes
|
|
136
|
+
- VISUAL_DEMO.py - Demonstração visual
|
|
137
|
+
|
|
138
|
+
### 🛠️ Arquivos de Implementação
|
|
139
|
+
- rule_field.py - Campo Django
|
|
140
|
+
- rule_widget.py - Widget
|
|
141
|
+
- rule_widget.html - Template
|
|
142
|
+
- rule_widget.js - JavaScript
|
|
143
|
+
- rule_widget.css - CSS
|
|
144
|
+
- views.py - API
|
|
145
|
+
- urls.py - URLs
|
|
146
|
+
|
|
147
|
+
### ⚙️ Scripts
|
|
148
|
+
- setup.sh - Setup automatizado
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 📈 Estatísticas
|
|
153
|
+
|
|
154
|
+
- **Total de Documentos:** 15 arquivos
|
|
155
|
+
- **Linhas de Documentação:** ~1.500+
|
|
156
|
+
- **Linhas de Código:** ~700+
|
|
157
|
+
- **Exemplos Funcionais:** 5+
|
|
158
|
+
- **Suites de Teste:** 5
|
|
159
|
+
- **Casos de Uso Cobertos:** 10+
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 🔗 Links Externos
|
|
164
|
+
|
|
165
|
+
- [rule-engine no PyPI](https://pypi.org/project/rule-engine/)
|
|
166
|
+
- [Documentação rule-engine](https://zerosteiner.github.io/rule-engine/)
|
|
167
|
+
- [Django Custom Model Fields](https://docs.djangoproject.com/en/stable/howto/custom-model-fields/)
|
|
168
|
+
- [CodeMirror](https://codemirror.net/)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 📝 Convenções de Nomenclatura
|
|
173
|
+
|
|
174
|
+
- `RuleField` - Classe do campo Django
|
|
175
|
+
- `RuleWidget` - Classe do widget
|
|
176
|
+
- `rule_field.py` - Arquivo do campo
|
|
177
|
+
- `rule_widget.*` - Arquivos do widget
|
|
178
|
+
- `/api/validate-rule/` - Endpoint da API
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 🎓 Níveis de Experiência
|
|
183
|
+
|
|
184
|
+
| Nível | Documento Recomendado |
|
|
185
|
+
|-------|----------------------|
|
|
186
|
+
| Iniciante | INSTALL.md → QUICKSTART.md |
|
|
187
|
+
| Intermediário | README.md → examples.py |
|
|
188
|
+
| Avançado | MIGRATION_GUIDE.md → Código fonte |
|
|
189
|
+
| Contribuidor | Todos os arquivos |
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 🗺️ Mapa do Conhecimento
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
┌─────────────────────────────────────────────────────────┐
|
|
197
|
+
│ COMEÇAR AQUI │
|
|
198
|
+
│ ↓ │
|
|
199
|
+
│ [INSTALL.md] │
|
|
200
|
+
│ ↓ │
|
|
201
|
+
│ [QUICKSTART.md] │
|
|
202
|
+
│ ↓ │
|
|
203
|
+
│ Precisa de mais detalhes? │
|
|
204
|
+
│ ↓ │
|
|
205
|
+
│ ┌────────────┴─────────────┐ │
|
|
206
|
+
│ ↓ ↓ │
|
|
207
|
+
│ [README.md] [examples.py] │
|
|
208
|
+
│ ↓ ↓ │
|
|
209
|
+
│ Customizar? Ver testes? │
|
|
210
|
+
│ ↓ ↓ │
|
|
211
|
+
│ [MIGRATION_GUIDE.md] [test_rule_field.py] │
|
|
212
|
+
│ ↓ ↓ │
|
|
213
|
+
│ Ver visual? Tudo OK! │
|
|
214
|
+
│ ↓ │
|
|
215
|
+
│ [VISUAL_DEMO.py] │
|
|
216
|
+
└─────────────────────────────────────────────────────────┘
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## ✅ Checklist de Aprendizado
|
|
222
|
+
|
|
223
|
+
- [ ] Li INSTALL.md e entendi o que foi criado
|
|
224
|
+
- [ ] Segui QUICKSTART.md e instalei com sucesso
|
|
225
|
+
- [ ] Li README.md e entendi a sintaxe de regras
|
|
226
|
+
- [ ] Vi examples.py e entendi casos de uso
|
|
227
|
+
- [ ] Executei test_rule_field.py com sucesso
|
|
228
|
+
- [ ] Testei no Django Admin
|
|
229
|
+
- [ ] Criei minha primeira regra
|
|
230
|
+
- [ ] Validei uma regra dinamicamente
|
|
231
|
+
- [ ] Li MIGRATION_GUIDE.md para customizar
|
|
232
|
+
- [ ] Implementei em meu projeto
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 💡 Dicas Finais
|
|
237
|
+
|
|
238
|
+
1. **Começe Simples** - Use exemplos básicos primeiro
|
|
239
|
+
2. **Teste Sempre** - Valide suas regras no admin antes de usar
|
|
240
|
+
3. **Leia os Exemplos** - O arquivo examples.py tem muitos casos práticos
|
|
241
|
+
4. **Use o Atalho** - Ctrl+Enter para validar é mais rápido
|
|
242
|
+
5. **Customize** - O campo é flexível, adapte para sua necessidade
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
**Versão:** 1.0.0
|
|
247
|
+
**Última Atualização:** Janeiro 2026
|
|
248
|
+
**Criado para:** Projeto AVA - IFRN
|
|
249
|
+
**Licença:** Mesmo do projeto principal
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
📧 **Precisa de ajuda?** Consulte a documentação relevante acima!
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# RuleField - Campo Django para Rule Engine
|
|
2
|
+
|
|
3
|
+
✨ **Campo Django customizado com editor visual e validação dinâmica**
|
|
4
|
+
|
|
5
|
+
## 📦 O que foi criado?
|
|
6
|
+
|
|
7
|
+
### Estrutura de Arquivos
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
src/base/
|
|
11
|
+
├── fields/
|
|
12
|
+
│ ├── __init__.py # Exporta RuleField
|
|
13
|
+
│ ├── rule_field.py # Campo Django customizado
|
|
14
|
+
│ ├── rule_widget.py # Widget para o admin
|
|
15
|
+
│ ├── README.md # Documentação completa
|
|
16
|
+
│ ├── QUICKSTART.md # Guia rápido
|
|
17
|
+
│ ├── examples.py # Exemplos de código
|
|
18
|
+
│ └── test_rule_field.py # Script de testes
|
|
19
|
+
├── templates/
|
|
20
|
+
│ └── widgets/
|
|
21
|
+
│ └── rule_widget.html # Template do widget
|
|
22
|
+
├── static/
|
|
23
|
+
│ └── rule_widget/
|
|
24
|
+
│ ├── rule_widget.js # JavaScript do widget
|
|
25
|
+
│ └── rule_widget.css # Estilos
|
|
26
|
+
└── api/
|
|
27
|
+
├── __init__.py
|
|
28
|
+
├── views.py # Endpoint de validação
|
|
29
|
+
└── urls.py # URLs da API
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🚀 Como Usar
|
|
33
|
+
|
|
34
|
+
### 1. Uso Básico
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from django_rule_engine.fields import RuleField
|
|
38
|
+
|
|
39
|
+
class MeuModelo(models.Model):
|
|
40
|
+
regra = RuleField(
|
|
41
|
+
verbose_name="Regra de Validação",
|
|
42
|
+
example_data={"idade": 25, "status": "ativo"}
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Criar Migrations
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cd src/
|
|
50
|
+
python manage.py makemigrations
|
|
51
|
+
python manage.py migrate
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. Coletar Arquivos Estáticos
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
python manage.py collectstatic --noinput
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 4. Testar no Admin
|
|
61
|
+
|
|
62
|
+
1. Acesse o Django Admin
|
|
63
|
+
2. Edite um objeto com RuleField
|
|
64
|
+
3. Veja o editor com syntax highlighting
|
|
65
|
+
4. Digite uma regra (ex: `idade >= 18 and status == "ativo"`)
|
|
66
|
+
5. Clique em **Validar** ou pressione **Ctrl+Enter**
|
|
67
|
+
6. Veja o resultado da validação
|
|
68
|
+
|
|
69
|
+
## ✨ Funcionalidades
|
|
70
|
+
|
|
71
|
+
- ✅ Editor de código com syntax highlighting (CodeMirror)
|
|
72
|
+
- ✅ Campo JSON de exemplo editável pelo usuário
|
|
73
|
+
- ✅ Validação dinâmica em tempo real
|
|
74
|
+
- ✅ Feedback visual (sucesso/erro)
|
|
75
|
+
- ✅ Atalhos de teclado (Ctrl+Enter para validar)
|
|
76
|
+
- ✅ API REST para validação
|
|
77
|
+
- ✅ Validação no backend
|
|
78
|
+
- ✅ Documentação completa
|
|
79
|
+
- ✅ Exemplos práticos
|
|
80
|
+
|
|
81
|
+
## 📝 Exemplos de Regras
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
# Idade mínima
|
|
85
|
+
"idade >= 18"
|
|
86
|
+
|
|
87
|
+
# Múltiplas condições
|
|
88
|
+
"idade >= 18 and status == 'ativo'"
|
|
89
|
+
|
|
90
|
+
# Email institucional
|
|
91
|
+
'"@ifrn.edu.br" in email'
|
|
92
|
+
|
|
93
|
+
# Regras complexas
|
|
94
|
+
"(preco > 100 or quantidade >= 5) and tipo_cliente == 'premium'"
|
|
95
|
+
|
|
96
|
+
# Com funções
|
|
97
|
+
"len(nome) > 3 and idade >= 18"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 🔧 Exemplo Implementado
|
|
101
|
+
|
|
102
|
+
O campo já está implementado no modelo `Cohort` em [coorte/models.py](../../../coorte/models.py):
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
class Cohort(models.Model):
|
|
106
|
+
name = CharField("cohort name", max_length=256, unique=True)
|
|
107
|
+
rule = RuleField(
|
|
108
|
+
"validation rule",
|
|
109
|
+
blank=True,
|
|
110
|
+
null=True,
|
|
111
|
+
example_data={
|
|
112
|
+
"login": "usuario123",
|
|
113
|
+
"user": {"email": "usuario@example.com"},
|
|
114
|
+
"name": "João da Silva",
|
|
115
|
+
"status": "Ativo"
|
|
116
|
+
},
|
|
117
|
+
default="login == 'usuario123' and user.email != 'usuario123@example.com'",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
class Meta:
|
|
121
|
+
verbose_name = _("cohort")
|
|
122
|
+
verbose_name_plural = _("cohorts")
|
|
123
|
+
ordering = ["name"]
|
|
124
|
+
|
|
125
|
+
def __str__(self):
|
|
126
|
+
return self.name
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 🧪 Testes
|
|
131
|
+
|
|
132
|
+
Execute os testes:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
cd src/
|
|
136
|
+
python manage.py shell
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Dentro do shell:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from django_rule_engine.fields.test_rule_field import test_all
|
|
143
|
+
test_all()
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Ou diretamente:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
python manage.py shell < base/fields/test_rule_field.py
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 📚 Documentação
|
|
153
|
+
|
|
154
|
+
- **[README.md](./README.md)** - Documentação completa e detalhada
|
|
155
|
+
- **[QUICKSTART.md](./QUICKSTART.md)** - Guia rápido de início
|
|
156
|
+
- **[examples.py](./examples.py)** - Exemplos de código prontos para usar
|
|
157
|
+
|
|
158
|
+
## 🌐 API
|
|
159
|
+
|
|
160
|
+
O endpoint de validação está disponível em:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
POST /api/validate-rule/
|
|
164
|
+
|
|
165
|
+
Body:
|
|
166
|
+
{
|
|
167
|
+
"rule": "idade >= 18 and status == 'ativo'",
|
|
168
|
+
"data": {"idade": 25, "status": "ativo"}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
Response:
|
|
172
|
+
{
|
|
173
|
+
"valid": true,
|
|
174
|
+
"result": true,
|
|
175
|
+
"matches": true
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 🎯 Próximos Passos
|
|
180
|
+
|
|
181
|
+
1. ✅ **Implementar no seu modelo** - Adicione `RuleField` onde precisar
|
|
182
|
+
2. ✅ **Criar migrations** - `python manage.py makemigrations`
|
|
183
|
+
3. ✅ **Aplicar migrations** - `python manage.py migrate`
|
|
184
|
+
4. ✅ **Testar no admin** - Acesse e edite um objeto
|
|
185
|
+
5. ✅ **Usar programaticamente** - Veja exemplos em `examples.py`
|
|
186
|
+
|
|
187
|
+
## 💡 Dicas
|
|
188
|
+
|
|
189
|
+
- Use `blank=True, null=True` se o campo for opcional
|
|
190
|
+
- Defina `example_data` relevante para seu caso de uso
|
|
191
|
+
- Teste suas regras no admin antes de usar em produção
|
|
192
|
+
- Consulte a [documentação do rule-engine](https://zerosteiner.github.io/rule-engine/)
|
|
193
|
+
|
|
194
|
+
## ❓ Suporte
|
|
195
|
+
|
|
196
|
+
- Leia [README.md](./README.md) para documentação completa
|
|
197
|
+
- Veja [examples.py](./examples.py) para casos de uso
|
|
198
|
+
- Consulte [QUICKSTART.md](./QUICKSTART.md) para início rápido
|
|
199
|
+
|
|
200
|
+
## 📄 Licença
|
|
201
|
+
|
|
202
|
+
Segue a licença do projeto principal.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
**Criado com ❤️ para o projeto AVA do IFRN**
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, kelsoncm
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|