Comments (13)
wouldn't @NotEmpty
decorator work?
from class-validator.
I am using skipmissingproperties and want to ensure that if a attribute is set, but not required will be validated and some attributes should be required and for example type of string.
I realized that if skipmissingproperties is set the validators are not executed at all. So also a NotEmpty will not work.... Do you have a solution for this kind of issue?
I need this to ensure that only validated data is saved in my database.
from class-validator.
I realized that if skipmissingproperties is set the validators are not executed at all.
if skipmissingproperties is set then validation are not being executed only on missing properties
So, you want to use skipmissingproperties, but at same time if some property is missing, but its totally required, you want skipmissingproperties to be ignore that that property. Do I get you right?
from class-validator.
@pleerock Exactly. I know which fields have which type and i know which fields are required. Some fields i know the datatype are not required but i need to ensure their data type if they have data.
from class-validator.
okay, got you. I'll think how do add option to decorators, so it will possible and let you know
from class-validator.
Okay, thank you very much. That sounds great!
from class-validator.
I think I can do NotEmpty
decorator the only decorator that will ignore skipmissingproperties
option. I don't see any benefit of doing it for any other decorator, and I don't see any benifit of ignoring NotEmpty in the cases when skipmissingproperties is set to true
from class-validator.
That would be great!
I am implementing a ODM layer and i have fields which are required and some (most) fields are not required.
A typical constellation will for example be @isnotempty @ISINT.
To ensure that its not empty and if filled it should be a integer.
I am pretty sure it only makes sense for IsNotEmpty.
from class-validator.
I changed my mind and decided to introduce a new decorator, as you originally suggested, but I named it @IsDefined()
. This will be available in upcoming release soon d25ce59
from class-validator.
added it in new version, you can try it by npm i class-validator@beta
from class-validator.
Wow. Thanks for this great new feature. Class-validator will be a huge part of my upcoming mongodb elasticsearch ORM - layer.
from class-validator.
thats great!
from class-validator.
fixed in 0.4.0
from class-validator.
Related Issues (20)
- fix: class-validators and nest.js: Global custom validator with imports from two different modules is only triggered in one of the two modules
- feature: traverse ValidationError.children HOT 1
- feature: add @IsTime HOT 3
- always: false doesn't take any effect
- question: How annotations are inherited ? HOT 1
- question: How can I validate a union of strings? HOT 1
- fix: @IsDateString() accepts wrong date format HOT 2
- fix: Cannot find namespace 'ValidatorJS' in 0.14.x HOT 8
- question: Could someone also bump the package.json version from 0.14.0 to 0.14.1? HOT 5
- fix: options for @IsBase64 decorator are ignored HOT 1
- docs: add changelog for 0.14.1
- Class-level validators
- question: How do I set a default error message for my decorator? HOT 2
- question: Default definition "strong password" is unclear HOT 3
- question: isPhoneNumber validation input without country code HOT 1
- question: nested validation but discriminated depending on a field value in the root dto HOT 3
- feature: return promise from validation only if necessary and validate sync if possible
- fix: Typo in MaxDate comment HOT 2
- question: get constrains in decorators and not the message HOT 1
- fix please: class level decorator makes bug 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 class-validator.