Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The backbone model's validate() function should match the predicates determined by the Django model's fields #2

Open
thedrow opened this issue Jan 5, 2013 · 0 comments
Assignees
Labels
Milestone

Comments

@thedrow
Copy link
Owner

thedrow commented Jan 5, 2013

User Story

As a web client I want to be able to validate the correctness of a model on the client side so that I will be able to get a more responsive answer about the model's correctness.

Example

    class TestModel(DjangoModel):
        test_id = fields.AutoField(primary_key=True)
        number = fields.IntegerField(default=1)
        string = fields.CharField(max_length=50, default="foo")

Should produce the following function:

{
//...
  validate: function()
  {
    if (typeof(this.get("test_id") != "number" && this.get("test_id") != null)
      return false;
    if (typeof(this.get("number ") != "number" && this.get("number ") != null)
      return false;
    if(this.get("string").length > 50 || (typeof(this.get("string") != "string" && this.get("string") != null)
      return false;
    return true;
  }
  //...
}
@ghost ghost assigned thedrow Jan 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant