ps-uteis
v0.0.2
Published
Funcoes uteis para aplicacoes node desenvolvidas pela primesoftware
Downloads
2
Readme
Funcoes uteis para aplicacoes node desenvolvidas pela primesoftware
🏠 Homepage
Install
npm install ps-uteis
Run tests
npm run test
How to use
const {ValidationContract, configReturn} = require('ps-uteis');
let chave = null;
let objReturn = configReturn(400);
let contract = new ValidationContract();
contract.isRequired(chave, "Chave");
#EXEMPLO RETORNO SEM ERRO
{
statusCode: 200,
statusDescription: 'Ok',
results: [],
description: '',
apiVersion: '1.0'
}
#EXEMPLO RETORNO COM ERRO
{
statusCode: 400,
statusDescription: 'Bad Request',
results: [],
description: 'Não foi possível concluir o procedimento! Verifique os campos obrigatórios.\n' +
'O campo Chave é obrigatório!',
apiVersion: '1.0'
}
if (!contract.isValid()) {
let returnsErrors = contract.erros();
let messageFinal = returnsErrors.description;
returnsErrors.results.forEach(error => {
messageFinal += `\n${error.mensagem}`;
});
objReturn.description = messageFinal;
} else {
objReturn = configReturn(200);
}
console.log(objReturn);
Author
👤 Cassio Fernandes
- Github: @cassfer
🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2021 Cassio Fernandes. This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator