Comments (4)
Isn't that like a locale issue?
from laravel-data.
At the moment such a thing is not possible:
- casts cannot create validation rules
- rule inferrers will always run and thus create the numeric rule
Something like this (#470) could maybe solve this. Since casts would be able to create their own rules in step one. In step two we could only generate nullable/optional rules and leave the numeric rule generation for what it is. The thing is, implementing that feature is a lot of work, so I'll hope to start soon working on this but it will take time.
As for now, why not overwrite the rules using a custom rules
method? That's probably the solution, and why I'm closing this issue. It can be fixed, agreed there are better solutions to this but it will take weeks time before they can be implemented.
from laravel-data.
As for now, why not overwrite the rules using a custom
rules
method? That's probably the solution, and why I'm closing this issue.
Hey @rubenvanassche thanks for the hint. That's a viable workaround, but please tell me what you meant by a custom rules
method. Did you mean to introduce a dummy rule that always validates?
I am doing it just with the #[WithoutValidation]
attribute, e.g. like this next to my custom casts:
#[WithoutValidation]
#[WithCast(CsvCast::class)]
#[WithTransformer(IdListTransformer::class)]
public null|array|Optional $contactGroupIds,
The #[WithoutValidation]
is basically needed everywhere where I cast some input type to another, or where I allow multiple different types as cast value.
from laravel-data.
Take a look at this section: https://spatie.be/docs/laravel-data/v3/as-a-data-transfer-object/request-to-data-object#content-rule-attribute after the first attributes.
The rules method always has precedence when generating rules over everything else.
from laravel-data.
Related Issues (20)
- Docs are out of date from this repo HOT 1
- Transforming to TypeScript requested a package Spatie\Enum HOT 4
- Can't include/exclude properties in collection since 4.5.0 HOT 1
- Lazy properties are not countable since v4 HOT 1
- validateAndCreate ignores rule from static rules method HOT 1
- Uncaught InvalidArgumentException: Non-backed enums have no default serialization
- Exception on validating typed fields HOT 1
- Dependencies fail to be injected into validation static override methods HOT 1
- Incorrect injection of routing parameters when using MapInputName HOT 2
- #[GreaterThan], #[GreaterThanOrEqualTo], #[LessThan], #[LessThanOrEqualTo] works not as expected (size comparision) HOT 2
- Backward compatibility is broken 4.5.1 🡒 4.6.0 HOT 1
- Array type is not cast or checked HOT 4
- Dot notation doesn't work with related model's property with MapInputName HOT 2
- Nested backed enum throwing error (must be of type Enum, string given)
- Relation with recursive reference causes infinite loop (even if it's not in the data) HOT 1
- Unable to transform data HOT 1
- Eager loaded relations are reset which throws a lazy loading violation HOT 1
- "Unique" validator with ignore parameter works wrong in sequentially run tests HOT 1
- Package does not support a `fromNull(null $null): null` handler HOT 1
- No documentation on spatie website for encrypted eloquent casting HOT 1
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 laravel-data.