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
There should be a way to introduce new custom types along with custom coercion and validations for the given type. It could be kind of like:
const{ createType, attributes }=require('structure');const{ isPlainObject, isString }=require('lodash');constGJV=require('geojson-validation');constGeoJSON=createType({test(value){returnisPlainObject(value);},coerce(value){if(isString(value)){returnJSON.parse(value);}thrownewTypeError("Value can't be coerced to GEOJson");},validations: {// `required` would be included by defaultfeature(validationArgument,value){varvalid;vardetails;GJV.isFeature(value,(isFeature,errors)=>{if(isFeature){valid=true;return;}details=errors;});if(valid){return{ valid };}return{errors: { details }};}}});constHouse=attributes({location: {type: GeoJSON,required: true,feature: true}})(classHouse{});
The validation errors could somehow use joi extension feature.
The text was updated successfully, but these errors were encountered:
There should be a way to introduce new custom types along with custom coercion and validations for the given type. It could be kind of like:
The validation errors could somehow use joi extension feature.
The text was updated successfully, but these errors were encountered: