nicolaslopezj/simple-react-form

Why need AttachSchema ?

Paul-Vandell opened this issue · 1 comments

Hey there,
Thx for this awesome packages but i got few questions...
In the basic example we have to attach the schema. But sometimes i need to only get a part of another schema like the Meteor.user.profile.
So I always need to create a new mongo collection 'null':
Example with just an Email Field that i need for user want to change his email address:

import SimpleSchema from 'simpl-schema';
import Text from 'simple-react-form-material-ui/lib/text';

const EmailDB = new Mongo.Collection(null); <=== Null
const EmailSchema = new SimpleSchema({
	email: {
		label: 'Adresse Mail',
		type: String,
		regEx: SimpleSchema.RegEx.Email,
		srf: {
			type: Text,
		},
	},
});
EmailDB.attachSchema(EmailSchema);<=== Need attach it just for the autoForm

export {EmailDB, EmailSchema};

But in another hand i would like to pick just the 'email field' from the Meteor.users per example...

We have other alternative with the "Uniforms packages" which take only the SimpleSchema but for few reason i would like to stay with yours.
With the AttachSchema we can have the from validation to the server side. So why use the attachSchema ? I think this is why Uniforms use only the SimpleSchema.
Do you have alternative about my issue ?
Thx in advance.

Version 2 is released without schema support. Now you have to build the form manually and pass theerrorMessages as a prop in the form component