I have requirement where I need to run some validations based on json data about controls. I have a file in JSON format in below format
{
"Activity List View" :[
{
"Activity Form Applet":{
"Asset Number": {"type":"text","minlength":5},
"Type":{"type":"text","maxlength":5},
"Comments":{"type":"text","email":"true"},
"Status":{"type":"number","maxlength":9},
"Priority":{"type":"text","minlength":5}
}
}
]
}
Basically I need to loop around this data and perform the validations as mentioned in the data and highlight the field if a validation fails.
I am new to jQuery so not aware how to go about it. As per my knowledge I can approach it in two ways.
Create a library of function that accept certain input and perform actions. It will be collections of functions like findElement, maxLength, minLength and so on.
Create a jQuery plugin and add same set of functions in plugin that performs the same functionality.
Due to my inexperience in jQuery the time required to complete will increase many fold. So I would like to know
What are the benefits of doing it jQuery plugin way rather than a library and are the benefits worth it?
Edit: based on the answers I can understand the benefits of sharing the plugin but are there any noticeable benefits in terms of Memory and performance (when used heavily)??