Comments (5)
Making the validator implement an interface doesn't sound intuitive to me. However, we can document that the messages property can use the CustomMessages
type.
from v5-docs.
If you put the callback right within the messages object, you will get types automatically, without being explicit about them.
messages: {
'*': (field, rule, arrayExpressionPointer, options) {
}
}
With that being said. It is technically valid to extract the method to a different file or maybe at the top in the same file. However, documentation cannot show all the styles, as it makes the docs verbose.
from v5-docs.
But the validator classes doesn't have this type information, not in the documentation either. I felt the need to search the codebase itself instead of reading from the document, is there another way I can help to improve this experience?
from v5-docs.
Can you please share how this can be improved? Or maybe just send a PR with the improvement :)
from v5-docs.
I can think 2 solutions for the class validators
- Import the
CustomMessages
interface at the example code in the validator classes documentation
import { schema, CustomMessages } from '@ioc:Adonis/Core/Validator'
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class CreateUserValidator {
constructor (protected ctx: HttpContextContract) {
}
public schema = schema.create({
})
public messages: CustomMessages = {}
}
- Introduce an interface for validator class itself, then change the example to have
implements Validator
export default class CreateUserValidator implements Validator{
// ...
}
from v5-docs.
Related Issues (20)
- dropUnique take an array as parameter, not a string
- Docs improvement HOT 2
- Docker compose volume issue
- Missing dcoumentation - String related `escape` and `trim` rules HOT 2
- Documentation for redirectToUrl seems to be outdated HOT 1
- `this.defer` does't work as expected in migrations HOT 1
- Global transactions documentation missing `await` keyword HOT 1
- [official doc bug] Testing upload image example seems out of date HOT 2
- Driver config: mysql2 HOT 2
- Incorrect documentation for validate mobile phone
- Wrong documentation for database driver config HOT 1
- fix: withCount exemple is uncorrect HOT 1
- Drive documentation references both `serveAssets` and `serveFiles` HOT 1
- Explanation for why to pick database vs redis api token storage
- Limiter documentation issue
- Documentation includes features that haven't been released yet. HOT 1
- Additional Example to Request Validation
- Documentation on Dockerizing AdonisJS incomplete HOT 1
- Include GET in HTTP method examples
- v5 algolia search points to v6 results HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v5-docs.