Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let stateObject = SW.getNewStateObject();
- SW.DataTypes.add("UserId", {
- structure: /[0-9]|[a-z]|[A-Z]/g,
- onValidate: (incomingValue) => {
- console.log(incomingValue);
- return true;
- },
- minLength: 1,
- required: true,
- nullable: false,
- defaultValue: null
- });
- //Standard contract
- stateObject.defineContract("ItemsContract", {
- id: SW.DataTypes.use("UserId"),
- name: SW.DataTypes.use("String", {
- defaultValue: null
- }),
- age: SW.DataTypes.use("Number"),
- email: SW.DataTypes.use("String"),
- password: SW.DataTypes.use("String", {
- hidden: true
- })
- });
- let contractItem = stateObject.createFromContract("ItemsContract", {
- id: String.prototype.toUniqueId(16),
- name: "Liviu"
- });
- console.log(contractItem); //{id: "tqYQWvW24P5NtJum", name: "Liviu", age: null, email: null, password: null}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement