Skip to content

chifundok/objectify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Objectify

Given a JSON schema like this...

{
  "title": "Person Schema",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    },
    "age": {
      "description": "Age in years",
      "type": "integer",
      "minimum": 0
    }
  },
  "required": ["firstName", "lastName"]
}

Build an object like this...

var person = {
  firstName: "",
  lastName: "",
  age: 0
};

By calling...

var billy =  Objectify.create(schema, { firstName: "billy" });

billy = {
  firstName: "billy",
  lastName: "",
  age: 0
};

Then validate.... using json-schema wrapper...

var isValid = Objectify.validate(schema, billy);
isValid = false // lastName is required

About

Given a JSON schema, create an instance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%