constschema=yup.object().shape({title: yup.string().required().min(4).max(50),description: yup.string().required().min(10).max(1000),ingredients: yup.array().min(1).max(10).of(yup.object().shape({name: yup.string().required().min(2).max(10),unit: yup.mixed().oneOf(["none","ounces","cups","pounds"]),amount: yup.number().min(1).max(30000),})),mainPicture: yup.mixed().required("Picture Required").fileMax({maxBytes: 50000,message:"Max Image size is 50MB",}).fileFormat({formats:["image/gif","image/jpeg","image/png"],message:"Images can only be png, gif, jpg",}),});
10. Try saving and notice it fails. It fails because we don't all the collection to be updated. Update your firebase storage rule and firestore rules to fix this.
Firestore
12345
match /recipes/{document=**} {
allow read: if true;
allow create: if request.auth != null;
allow update: if request.auth != null && request.auth.uid == resource.data.userId;
}
Firestorage
1 2 3 4 5 6 7 8 91011
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read: if true;
}
match/{userId}/{allPaths=**} {
allow write: if request.auth != null && request.auth.uid == userId;
}
}
}