This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZaynJarvis
approved these changes
Feb 9, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good implementation. Thx.
Will try to work out how to implement this into admin site
It's a good implementation on validation. |
This was referenced Feb 12, 2019
It's a good implementation.
Uncaught (in promise) Error: Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: undefined
at new FirestoreError (index.cjs.js:404)
at validateType (index.cjs.js:730)
at validateArgType (index.cjs.js:631)
at CollectionReference.doc (index.cjs.js:24743)
at PeopleRepository.<anonymous> (people.repository.js:39)
at step (tslib.es6.js:197)
at Object.next (tslib.es6.js:127)
at tslib.es6.js:100
at new Promise (<anonymous>)
at Module.__awaiter (tslib.es6.js:77)
at people.repository.js:32
at new Promise (<anonymous>)
at Function.PeopleRepository.validate_js_1.validators.personExists (people.repository.js:31)
at Function.runValidations (validate.js:132)
at validate (validate.js:22)
at Object.validateArtwork [as validate] (function.js:23)
at formik.esm.js:668
at new Promise (<anonymous>)
at Formik.runValidateHandler (formik.esm.js:667) export const validateArtwork = values =>
flattern(validate(values, ARTWORK_CONSTRAINTS));
// the framework i use doesn't allow multiple errors, so I map only the first error.
export const flattern = obj =>
obj
? Object.keys(obj)
.map(key => ({ [key]: obj[key][0] }))
.reduce((agg, item) => ({ ...agg, ...item }))
: {};
{
venue: '',
banner: '',
status: 'draft',
facebook: {
url: '',
status: 'draft',
id: '',
},
eventbrite: {
url: '',
status: 'draft',
id: '',
},
dependencies: [
{
referenceUrl: '',
specification: '',
label: '',
},
],
prerequisites: [
{
referenceUrl: '',
proficiency: 'basic',
label: '',
},
],
speakers: [
{
position: '',
organisation: '',
person: '',
},
],
endTime: '2019-01-01T18:30',
startTime: '2019-01-01T18:30',
hasDrinks: '',
hasFood: '',
isExternal: '',
isPublic: '',
remarks: '',
promotion: '',
description: '',
githubUrl: '',
tagline: '',
title: '',
tgif: 'd',
} export const validateEvent = values => {
console.log(JSON.stringify(values, null, 2));
const x = validate(values, EVENT_CONSTRAINTS);
console.log(`x = ${x}`);
}; In this case console.log line hasn't been triggered. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To use
LOCATION_CONSTRAINTS
,ORGANISATION_CONSTRAINTS
, andPERSON_CONSTRAINTS
, please use validate.js'svalidate
method to validate model attributes against the defined constraints.For
ARTWORK_CONSTRAINTS
andEVENT_CONSTRAINTS
usevalidate.async
to correctly use these constraints. These are written in an async fashion to support existential verification of referenced documents which require requests using firebase library. More info here.@ZaynJarvis I think this will be useful in form validation when creating events or entities via ntuoss/hackoss-admin. I've defined these according to the assumptions that were presumed to be true at the time of writing but have not tested if they actually work. Need your help to check if they make sense and if they're functional.
Resolves #5. Hopefully this makes it easier to implement ntuoss/hackoss-admin#3.
Thanks!