adopted-ember-addons / adopted-ember-addons/ember-cp-validations
add a special case for default url format validation
- Langage dominant
- JavaScript
- Étoiles
- 439
- Forks
- 172
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
### Environment
- Ember Version: 2.18.2
- Ember CLI Version:2.15.1
- Ember CP Validations Version:4.0.0-beta.1
### Steps to Reproduce
The default format validator for url will return false for the shortened urls from our company's tiny url generator. (eg. http://bburl/abcd), so I want to add a special case to the default url format validator.
I wonder whether you could add that special case to the default url format validator?
After I upgrade the ember-cp-validations to 4.0.0-beta.1, I find a working solution, which is to create a customized validator.
```
export default BaseValidator.extend({
validate(value) {
const result = this.test('format', value, {
type: 'url',
allowBlank: true
});
const bburl = /^(https?:\/\/bburl)/;
if (result.isValid || bburl.test(value)) {
return true;
} else {
return 'Has to be in a valid URL format';
}
}
});
```
I wonder whether you could make the change on your side, if not, what is your suggestion on this issue? Thank you!
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Start by locating the default URL format validator and compare its behavior with the customized validator shown in the issue. Confirm how shortened URLs such as http://bburl/abcd should be handled while preserving normal URL validation; done means the intended URLs validate successfully.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- frontend
- Type d'issue
- Fonctionnalité
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100