ffffng/shared/validation/constraints.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-05-12 20:08:19 +02:00
'use strict';
angular.module('ffffng').factory('Constraints', function () {
return {
id:{
regex: /^[1-9][0-9]*/,
optional: false
},
2014-05-12 20:08:19 +02:00
token:{
regex: /^[0-9a-f]{16}$/i,
2014-05-12 20:08:19 +02:00
optional: false
},
node: {
hostname: {
regex: /^[-a-z0-9_]{1,32}$/i,
2014-05-12 20:08:19 +02:00
optional: false
},
key: {
regex: /^([a-f0-9]{64})$/i,
2014-05-12 20:08:19 +02:00
optional: true
},
email: {
regex: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
2014-05-12 20:08:19 +02:00
optional: false
},
nickname: {
regex: /^[-a-z0-9_ äöüß]{1,64}$/i,
2014-05-12 20:08:19 +02:00
optional: false
},
mac: {
regex: /^([a-f0-9]{12}|([a-f0-9]{2}:){5}[a-f0-9]{2})$/i,
2014-05-12 20:08:19 +02:00
optional: false
},
coords: {
regex: /^(-?[0-9]{1,3}(\.[0-9]{1,15})? -?[0-9]{1,3}(\.[0-9]{1,15})?)$/,
optional: true
}
}
};
});