Skip to content

Instantly share code, notes, and snippets.

View marcusholloway17's full-sized avatar
💭
I may be slow to respond.

Marcus marcusholloway17

💭
I may be slow to respond.
View GitHub Profile
@marcusholloway17
marcusholloway17 / readme.md
Created March 30, 2024 11:06
Implementer la validation requireIf avec express-validator

requiredIf est une condition de validation avec express-validator qui permet de rendre un champ obligatoire seulement si une certaine condition est remplie. Cependant, express-validator n'inclut pas une règle requiredIf prédéfinie directement comme dans certains frameworks de validation. Néanmoins, tu peux implémenter cette logique en utilisant les fonctionnalités personnalisées de validation qu'express-validator offre.

Voici comment tu pourrais implémenter une validation requiredIf :

1. Utiliser une Validation Conditionnelle :

Tu peux créer une condition qui vérifie si un autre champ répond à certains critères et, basé sur cela, appliquer la validation requise sur le champ en question.

2. Utiliser .custom() pour les validations personnalisées :

.custom() te permet de définir une fonction de validation où tu peux mettre en place n'importe quelle logique. Supposons que tu veuilles rendre le champ monChamp requis si un autre champ conditionChamp est égal à une certaine valeur. Voici comment

@marcusholloway17
marcusholloway17 / readme.md
Created March 24, 2024 09:03
How To Install NVM on Ubuntu 22.04

Prerequisites

  • You must have a running Ubuntu 22.04 Linux system with shell access.
  • Log in with a user account to which you need to install node.js.

Step 1: Installing NVM on Ubuntu

sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
@marcusholloway17
marcusholloway17 / readme.md
Created January 27, 2024 14:24
INSTALL NVM ON MAC

1- create .zshrc file if not exist :

touch ~/.zshrc

2- run the command below:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
@marcusholloway17
marcusholloway17 / readme.md
Last active October 4, 2023 20:09
HOW TO FIX FIX DETACHED HEAD ERROR

HOW TO FIX FIX DETACHED HEAD ERROR

When working in Live Development mode, attempting to push your changes using git push can occasionally fail with a message similar to the following:

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

This detached head state occurs when a specific commit is checked out instead of a branch. You cannot commit to a commit—only to a branch. To correct this, use the following steps to create a branch for your commits: