Skip to content

Releases: esbanarango/ember-model-validator

v3.12.0

29 Dec 22:02
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v3.11.0...v3.12.0

Release v3.11.0

03 Sep 02:45
Compare
Choose a tag to compare

💥 Breaking Change

Decorator instead of mixin

Before

import Model from "ember-data/model";
import attr from "ember-data/attr";
import Validator from "ember-model-validator/mixins/object-validator";

export default Model.extend(Validator, {
  fullName: attr("string"),
  fruit: attr("string"),
  color: attr("string"),

  validations: {
    fullName: {
      presence: true
    },
    fruit: {
      presence: true
    }
  }
});

After

import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import Validator from 'ember-model-validator/decorators/model-validator';

@Validator
class MyModel extends Model {
  @attr("string") fullName;
  @attr("string") fruit;
  @attr("string") color;

  validations = {
    fullName: {
      presence: true
    },
    fruit: {
      presence: true
    }
  }
}

export default MyModel;

Adding exclusion validator and support for custom message.

19 May 02:00
Compare
Choose a tag to compare
  validations: {
    name: {
      presence: true,
      inclusion: { in: ['Jose Rene', 'Aristi Gol', 'Armani'], message: 'Solo verde a morir' }
    },
    secondName: {
      exclusion: { in: ['Gionvany Hernandez', 'Wilder Medina'], message: 'Que iNrresponsabilidad' }
    },
    bussinessEmail: {
      presence: { message: 'sup dude, where\'s da email' },
      email: { message: 'Be professional ma men' }
    },
    mainstreamCode: {
      format: { with: /^[a-zA-Z]+$/, message: 'nu nu, that\'s not the format' }
    }
    alibabaNumber: {
      numericality: { message: 'is not abracadabra' }
    }
  }

Addition of Format validator + default messages.

18 May 02:50
Compare
Choose a tag to compare

format: {with: /^[a-zA-Z]+$/}

New DSL to define validations + Numericality

15 May 13:08
Compare
Choose a tag to compare

Before:

validations: {
  presence: ['name','email'],
  email: ['email'],
  relations: {
    hasMany:['otherFakes']
  }
}

Now:

  validations: {
    name: {
      presence: true
    },
    email: {
      presence: true,
      email: true
    },
    lotteryNumber: {
      numericality: true
    },
    otherFakes:{
      relations: ['hasMany']
    }
  }

Basic validations / First release!

14 May 04:22
Compare
Choose a tag to compare