You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Samchon! First off, thank you for making this great library.
I am currently iterating over my collections and am validating all items in my database. With typia, this has been made very easy and it's easy to find instances where my data and types have diverged.
However, when it comes to nested arrays, the validation reporting is not terribly helpful, as it does not appear to serialize objects. Would it be possible to serialize the objects on validation printouts if not primitive? I suppose this may be problematic for recursive data structures, but perhaps an opt-in option to allow doing so would be helpful. Or perhaps object serialization is already handled and this is simple an issue with nested arrays.
sample script doing the validation:
import{Db,MongoClient}from'mongodb'import{createValidate,IValidation}from'typia'import{Element}from'../src/types/element'import{TrainingAudience,TrainingEvaluation,TrainingGoal}from'../src/types/training'constcollectionValidators={'training.audiences': createValidate<TrainingAudience>(),'training.goals': createValidate<TrainingGoal>(),'training.evaluations': createValidate<TrainingEvaluation>(),elements: createValidate<Element>(),}asyncfunctionmain(){console.log('Attempting to connect to DB')constclient=awaitMongoClient.connect('mongodb://admin:password@localhost:27017',)try{constdb=client.db('database')for(constcollectionValidatorofObject.entries(collectionValidators)){awaitvalidateCollection(db, ...collectionValidator)}}catch(error){console.error(`Error: ${error}`)}finally{awaitclient.close()console.log('DB connection closed')}}asyncfunctionvalidateCollection(db: Db,collectionName: string,validate: (input: unknown)=>IValidation,){console.log(`Validating ${collectionName}`)constcursor=db.collection(collectionName).find({})forawait(constdocofcursor){constres=validate(doc)if(!res.success){console.error(`Validation failed for ${doc.metadata.uuid}`)console.log(res.errors)}}}main()
Hi Samchon! First off, thank you for making this great library.
I am currently iterating over my collections and am validating all items in my database. With typia, this has been made very easy and it's easy to find instances where my data and types have diverged.
However, when it comes to nested arrays, the validation reporting is not terribly helpful, as it does not appear to serialize objects. Would it be possible to serialize the objects on validation printouts if not primitive? I suppose this may be problematic for recursive data structures, but perhaps an opt-in option to allow doing so would be helpful. Or perhaps object serialization is already handled and this is simple an issue with nested arrays.
sample script doing the validation:
Output from validation errors:
The text was updated successfully, but these errors were encountered: