Skip to content

Instantly share code, notes, and snippets.

View js-ms's full-sized avatar

Juan Sebastián Marulanda Sánchez js-ms

  • Manizales, Caldas, Colombia
View GitHub Profile
@js-ms
js-ms / Uuid.js
Last active February 6, 2020 20:19
Provider created for making the uuid stored as Binary(16) readable as a string (Adonisjs)
/**
** You only need to put this file inside your Traits
** Feel free to contribute
** to call it in your models just put this.addTrait('Uuid');
** if you want to create the trait with options,
** just pass the uuid properties array: this.addTrait('Uuid', ['field']);
** each position in the array refers to a key with uuid format inside your model
** another way is creating a get function, e.g: get uuidFields() { return ['field1', 'field 2']; }
**/
@js-ms
js-ms / PhoneValidator.js
Created March 12, 2019 14:35
Validation Provider for Phone AdonisJS extending Validator
const { ServiceProvider } = require('@adonisjs/fold')
class PhoneProvider extends ServiceProvider {
async phone(data, field, message, args, get){
const value = get(data, field);
if (!value) {
return
}
@js-ms
js-ms / LatitudeProvider.js
Created March 12, 2019 14:14
Validation for latitude with AdonisJS/Indicative (Extending Validator)
const { ServiceProvider } = require('@adonisjs/fold')
class LatitudeProvider extends ServiceProvider {
async lat(data, field, message, args, get){
const value = get(data, field);
if (!value) {
return
}