Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mamedul committed Jan 22, 2022
1 parent d951135 commit 94f3378
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 47 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# objectpropvalidator changelog


## Version 1.0.0 (January 23, 2022)-Initial Release
* Upload and public release the initial version.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 mamedul
Copyright (c) 2022 by Mamedul Islam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
98 changes: 91 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,82 @@
# objectpropvalidator
-simple and fine object properties validation checker

-Simple and smallest fine object properties validation checker with suggestions using console


## Features

* Simple and smallest size

* NodeJS compatible

* ExpressJS compatible

* Easy to use and short coding

* Small size (less than 3KB)

* Suggestion to validation (exact location)

* Custom configuration

* Custom logger configuration




## Installations

objectpropvalidator is available on [npmjs](https://www.npmjs.com/package/objectpropvalidator) (using semantic versioning), and can install via npm command.

```
npm install objectpropvalidator
```
or

```
npm i objectpropvalidator
```
or

```
npm save objectpropvalidator
```

Or you can use CDN in your HTML file-

```html
<script src="https://cdn.jsdelivr.net/npm/objectpropvalidator@1.0.0/src/objectpropvalidator-v1.0.0.min.js""></script>
```
or
```html
<script src="https://cdn.jsdelivr.net/npm/objectpropvalidator@1.0.0/src/objectpropvalidator-v1.0.0.min.js""></script>
```

Or you can use locally downloaded file in your HTML file-

```html
<script src="./pathname/src/objectpropvalidator-v1.0.0.min.js"></script>
```


## How to use

-Simple to use

```
```html
objectPropValidator(validationObject).(data)
```
With configuration object-
```

or
With configuration object-
```html
objectPropValidator(validationObject,config).(data)
```


## Example

-If there has any error or invalid data, it will show error base on your configuration. Default error log via `console.error`

```html
Expand All @@ -21,6 +85,7 @@ objectPropValidator(validationObject,config).(data)

<script>
// We check this data validity
var data = {
"props": {
"user": {
Expand Down Expand Up @@ -51,13 +116,32 @@ objectPropValidator(validationObject,config).(data)
}
};
// Configurations
var config = {
enabled: true,
logLevel: 'log' //console.log
enabled: true, // Configuration enabled
logLevel: 'log' // suggestion show via console.log
};
objectPropValidator(validationObject,config).(data)
objectPropValidator(validationObject,config)(data);
</script>
```



## Documentation

Check the [documentations here.](https://github.com/mamedul/objectpropvalidator/wiki)



## License

`objectpropvalidator` javascript library is Licensed under the [MIT license](https://github.com/mamedul/objectpropvalidator/blob/master/LICENSE).



## Contributing

The library is developed by [MAMEDUL ISLAM](https://mamedul.github.io).
72 changes: 41 additions & 31 deletions examples/example1.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<title>Example 1 || objectpropvalidator :: Developed by MAMEDUL ISLAM</title>
</head>
<body>

Expand All @@ -18,44 +18,54 @@
Additionally, when the value is false the function should log a helpful error
message specific to the mode of failure.

<script src="./objectpropvalidator.js"></script>
<br>
<br>
<a href='https://github.com/mamedul/objectpropvalidator/wiki'>Documentations</a>
<br>
<a href='https://mamedul.github.io/dev-projects/objectpropvalidator/'>Project Homepage</a>
<br>
<a href='https://mamedul.github.io'>Developer</a>

<script>

var users = {

<script src="../src/objectpropvalidator-v1.0.0.min.js"></script>

<script>

"props": {
var users = {

"user": {
"name": "MAMEDUL ISLAM",
"age": 26
}
"props": {

"user": {
"name": "MAMEDUL ISLAM",
"age": 26
}

};

//
objectPropValidator( { props: {
user: {
type: Object,
required: true,
validator: objectPropValidator({
name: {
type: String,
required: true,
},
age: {
type: Number,
required: true,
validator(value) {
return value > 0;
},
}

};


objectPropValidator( { props: {
user: {
type: Object,
required: true,
validator: objectPropValidator({
name: {
type: String,
required: true,
},
age: {
type: Number,
required: true,
validator(value) {
return value > 0;
},
}),
},
}
} )(users);
},
}),
},
}
} )(users);

</script>
</body>
Expand Down
78 changes: 78 additions & 0 deletions examples/example2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example 1 || objectpropvalidator :: Developed by MAMEDUL ISLAM</title>
</head>
<body>

I need a function for Object prop validation where it takes input object similar to props
where each key is the name of an expected property, and each value may contain information
about the type, required, and validator for that property.

Output: returns a new validator function which itself takes an object as an input and
returns true or false depending on whether the object conforms to the schema.

Additionally, when the value is false the function should log a helpful error
message specific to the mode of failure.

<br>
<br>
<a href='https://github.com/mamedul/objectpropvalidator/wiki'>Documentations</a>
<br>
<a href='https://mamedul.github.io/dev-projects/objectpropvalidator/'>Project Homepage</a>
<br>
<a href='https://mamedul.github.io'>Developer</a>



<script src="../src/objectpropvalidator-v1.0.0.min.js"></script>

<script>

// We check this data validity
var data = {
"props": {
"user": {
"name": "MAMEDUL ISLAM",
"age": 26
}
}
};

// Validation object
var validationObject = { props: {
user: {
type: Object,
required: true,
validator: objectPropValidator({
name: {
type: String,
required: true,
},
age: {
type: Number,
required: true,
validator(value) {
return value > 0;
},
},
}),
},
}
};

// Configurations
var config = {
enabled: true, // Configuration enabled
logLevel: 'log' // suggestion show via console.log
};


objectPropValidator(validationObject,config)(data);

</script>
</body>
</html>
52 changes: 52 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "objectpropvalidator",
"version": "1.0.0",
"description": "Simple and smallest fine object properties validation checker with suggestions using console.",
"main": "./src/objectpropvalidator-v1.1.0.min.js",
"directories": {
"doc": "docs",
"example": "examples"
},
"scripts": {
"test": "objectpropvalidator"
},
"keywords": [
"objectpropvalidator",
"objectpropvalidator",
"Javascript",
"Javascript Object",
"Object Validator",
"Object Validation",
"Object Property",
"Object Properties",
"Object Property Validator",
"Object Properties Validator",
"Object Property Validation",
"Object Properties Validation",
"Object Properties Validation Function",
"Object Properties Validation Fast Function",
"Object Properties Validation Function with Suggestion",
"Library",
"Framework",
"mamedul",
"momedul",
"mamedul islam",
"momedul islam",
"www.mamedul.ml",
"Freelancer",
"Developer",
"Javascript Developer",
"Bangladesh"
],
"author": "MAMEDUL ISLAM",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/mamedul/objectpropvalidator.git"
},
"bugs": {
"url": "https://github.com/mamedul/objectpropvalidator/issues"
},
"homepage": "https://mamedul.github.io/dev-projects/objectpropvalidator/"
}

Loading

0 comments on commit 94f3378

Please sign in to comment.